eureka配置https
时间: 2024-06-19 11:02:28 浏览: 210
eureka配置详解
Eureka是Netflix开发的服务发现组件,它可以帮助开发者实现微服务架构中的服务注册与发现。关于Eureka配置HTTPS,需要进行以下几个步骤:
1. 生成证书
可以使用openssl生成证书,具体操作可以参考openssl文档。
2. 配置Eureka Server
在Eureka Server的配置文件application.yml中进行如下配置:
```
server:
port: 8761
ssl:
key-store: classpath:/server.jks
key-store-password: password
key-password: password
client-auth: need
trust-store: classpath:/server_truststore.jks
trust-store-password: password
eureka:
instance:
secure-port-enabled: true
non-secure-port-enabled: false
server:
wait-time-in-ms-when-sync-empty: 0
enable-self-preservation: false
client:
registry-fetch-interval-seconds: 5
initial-instance-info-replication-interval-seconds: 0
register-with-eureka: false
fetch-registry: false
```
3. 配置Eureka Client
在Eureka Client的配置文件application.yml中进行如下配置:
```
eureka:
instance:
hostname: ${eureka.instance.hostname}
non-secure-port: ${server.port}
secure-port-enabled: true
secure-port: ${server.ssl.port}
home-page-url-path: https://${eureka.instance.hostname}:${server.ssl.port}/
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: https://localhost:8761/eureka/
```
注意:以上配置仅供参考,实际操作可能需要根据具体情况进行调整。
阅读全文