`
m15143285903
  • 浏览: 14869 次
文章分类
社区版块
存档分类
最新评论

eureka 获取服务器正确的公网ip

阅读更多

个别服务器,比如虚拟服务器等,很多网关网卡做了很多映射或者很多虚拟网卡,

容易导致eureka 客户端不能获取到正确的公网ip地址,容易直接获取局域网IP,

导致服务注册不到eureka服务端

这种情况,把相应服务的公网ip 在配置文件中写固定

配置如下:

#使用IP访问注册中心(生产环境时设置为true)
eureka.instance.prefer-ip-address: true
#在注册中心status的时候显示的格式,这里是 ip:端口 
eureka.instance.instance-id: ${spring.cloud.client.ipAddress}:${server.port}
eureka.instance. hostname:${spring.cloud.client.ipAddress}
#把指向eureka的ip固定写上, 用于eureka在服务器上不能获取正确的ip导致注册无效
#eureka.instance.ip-address:113.120.4.29 

from: www.1b23.com

把这个地方,加一句

 eureka.instance.ip-address:113.120.4.29

 此Ip 根据相应服务的实际公网ip地址,不是eureka 服务端Ip,  是客户端ip ,指向注册中心的那个地方的ip是 eureka 服务的IP, 这个地方,别弄混了

 

1
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics