使用特定端口在eureka中注册spring boot https应用程序
我正在尝试注册一个仅通过https可用的应用程序。我的配置不正确,eureka仪表板中显示的链接不正确。我尝试了一些配置,但无法获得正确的效果,即在Eureka中使用仪表板链接 我的基本配置使用特定端口在eureka中注册spring boot https应用程序,spring,spring-boot,https,netflix-eureka,spring-cloud-netflix,Spring,Spring Boot,Https,Netflix Eureka,Spring Cloud Netflix,我正在尝试注册一个仅通过https可用的应用程序。我的配置不正确,eureka仪表板中显示的链接不正确。我尝试了一些配置,但无法获得正确的效果,即在Eureka中使用仪表板链接 我的基本配置 server: port: 9999 context-path: /ctx ssl: key-store: classpath:keystore.jks key-store-password: 'kspass' key-password: 'kpass' keyA
server:
port: 9999
context-path: /ctx
ssl:
key-store: classpath:keystore.jks
key-store-password: 'kspass'
key-password: 'kpass'
keyAlias: ssl
spring:
application:
name: app-ctx
cloud:
loadbalancer:
retry:
enabled: true
eureka:
client:
serviceUrl:
defaultZone: https://localhost:8761/eureka/
instance:
hostname: localhost
secure-port-enabled: true
non-secure-port-enabled: false
secure-port: ${server.port}
health-check-url: https://${eureka.hostname}:XYZ/ctx/health
status-page-url: https://${eureka.hostname}:XYZ/ctx/info
home-page-url: https://${eureka.hostname}:XYZ/ctx
我尝试了以下版本的健康/状态/主页URL:
最后一个与我的期望非常接近,但是没有https,我终于找到了问题的解决方案。不确定这是否是最好的,因为据我所知,它不适用于随机端口,即server.port=0。在这种情况下,eureka使用端口0注册应用程序,并且在仪表板上存在与端口的链接,该链接不会转发到正确的位置,这不是预期的行为 我们必须使用配置${eureka.instance.secure port}的eureka部分,而不是使用与当前应用程序相关的${server.port}占位符,即
server:
port: 9999
context-path: /ctx
ssl:
key-store: classpath:keystore.jks
key-store-password: 'kspass'
key-password: 'kpass'
keyAlias: ssl
spring:
application:
name: app-ctx
cloud:
loadbalancer:
retry:
enabled: true
eureka:
client:
serviceUrl:
defaultZone: https://localhost:8761/eureka/
instance:
hostname: localhost
secure-port-enabled: true
non-secure-port-enabled: false
secure-port: ${server.port}
health-check-url: https://${eureka.instance.hostname}:${eureka.instance.secure-port}/ctx/health
status-page-url: https://${eureka.instance.hostname}:${eureka.instance.secure-port}/ctx/info
home-page-url: https://${eureka.instance.hostname}:${eureka.instance.secure-port}/ctx
我自己还没有测试过,但这可能会有所帮助:,请注意,他们使用的是securePortEnabled,而不是SecurePort-enabled@ShmulikAsafi不,没用。在这种情况下,属性名约定并不重要,因为spring boot使用的是轻松绑定器/属性解析器。非常有用,谢谢。请注意,
eureka.instance.hostname
在您的配置中非常重要。