在具有Jhipster微服务结构的项目中,注册表,网关和UAA在Docker容器中运行,并且也在同一服务器上的容器中运行的其他服务与注册表通信并进行身份验证,但是我其他服务器中有服务,如何与注册表通信外部服务并进行身份验证?
Docker服务器IP:10.10.10.10
首先,我试图对Registry的application.yml和其中一项服务进行更改,以使连接/通信是通过服务器ip而不是容器的ip。
我当前的设置是:
在容器application.yml中注册
eureka:
instance:
appname: jhipster-registry
instanceId: jhipsterRegistry:${spring.application.instance-id:${random.value}}
hostname: 10.10.10.10
prefer-ip-address: false
lease-renewal-interval-in-seconds: 5
lease-expiration-duration-in-seconds: 10
status-page-url-path: ${management.endpoints.web.base-path}/info
health-check-url-path: ${management.endpoints.web.base-path}/health
metadata-map:
zone: primary # This is needed for the load balancer
profile: ${spring.profiles.active}
version: ${info.project.version}
client:
enabled: true
fetch-registry: false
register-with-eureka: false
instance-info-replication-interval-seconds: 10
registry-fetch-interval-seconds: 10
service-url:
defaultZone: http://admin:${spring.security.user.password:admin}@localhost:${server.port}/eureka/
server:
# see discussion about enable-self-preservation:
# https://github.com/jhipster/generator-jhipster/issues/3654
enable-self-preservation: false
dashboard:
path: /registry
datacenter: JHipster-DataCenter
environment: JHipster-Environment
另一个服务器应用程序上的服务。yml
eureka:
instance:
prefer-ip-address: false
hostname: http://10.10.10.10
client:
service-url:
defaultZone: http://admin:${jhipster.registry.password}@10.10.10.10:8761/eureka/