我正在尝试为我的 Spring Cloud 应用程序启用 SSL。现在它由几个服务组成,Eureka 和 Zuul(没有 Ribbon 或 Feighn)。我发现很少有关于如何为 Eureka 启用 SSL 的提示,但无法让它工作。在 Zuul 方面,我找不到任何信息,除了这个:Zuul SSL Support,它有效地禁止使用随机端口:(server.port=0)。我的应用程序的 application.yml:
server:
port: 0
ssl:
key-store: classpath:keystore.jks
key-store-password: password
key-password: password
endpoints:
restart:
enabled: true
shutdown:
enabled: true
health:
sensitive: false
eureka:
instance:
leaseRenewalIntervalInSeconds: 10
metadataMap:
instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${server.port}}}
client:
registryFetchIntervalSeconds: 5
logging:
level:
com.netflix.discovery: 'OFF'
Eureka 服务器 application.yml:
server:
port: 8761
ssl:
key-store: classpath:keystore.jks
key-store-password: password
key-password: password
eureka:
instance:
hostname: localhost
securePort: ${server.port}
securePortEnabled: true
nonSecurePortEnabled: false
secureVirtualHostName: ${spring.application.name}
homePageUrl: https://${eureka.instance.hostname}:${server.port}/
statusPageUrl: https://${eureka.instance.hostname}:${server.port}/admin/info
metadataMap:
hostname : ${eureka.instance.hostname}
securePort: ${server.port}
server:
waitTimeInMsWhenSyncEmpty: 0
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
我不确定我需要在 Zuul 的 application.yml 中添加什么来允许 SSL,所以我跳过它。
当我启动 Eureka 和我的应用程序时,我遇到了重复的异常:
2015-07-19 12:46:42.527 INFO 7972 --- [pool-7-thread-1] o.a.http.impl.client.DefaultHttpClient : I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {}->http://localhost:8761: The target server failed to respond
2015-07-19 12:46:42.527 INFO 7972 --- [pool-7-thread-1] o.a.http.impl.client.DefaultHttpClient : Retrying request to {}->http://localhost:8761
我也得到 404 到 curl 命令:
curl -k -i -X 获取https://localhost:8761/eureka
Zuul 无法启动,因为它无法连接到 Eureka。
我很确定我将配置文件放入了错误的 application.yml 文件中(我仍然不知道如何配置 Zuul)。
我想知道是否有任何文档告诉如何在所有 Netflix 组件中启用 SSL。