eureka在服务器中不能获取正确的公网ip

个别服务器,好比虚拟服务器等,不少网关网卡作了不少映射或者不少虚拟网卡,java

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

致使服务注册不到eureka服务端服务器

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

配置以下:code

#使用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

把这个地方,加一句server

 eureka.instance.ip-address:113.120.4.29ip

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