SpringCoud+nacos is deployed in a multi-ip environment to unify the nacos service registration ip
scene description
在部署SpringCoud项目的时候分服务器部署注册同一个nacos服务,但是在服务器有多个ip存在的同时(内外网),就会出现注册服务ip不同的问题,导致一些接口无法连接访问,经过多次排查终于找到问题并找到解决方法,亲测有效!!!
method
-
Configure a fixed ip
in the bootstrap.yml file under the springcloud service
Specify the ip port
under application.properties
Specify the ip port
spring.cloud.nacos.discovery.ip = 127.0.0.1
spring.cloud.nacos.discovery.port = 8989 -
Configure the ip using the intranet prefix
spring.cloud.inetutils.preferred-networks=10.25.14
Use the ip prefix of 10.25.14, such as: 10.25.14.12, 10.25.14.13. -
Configure the fixed network card configuration item
spring.cloud.nacos.discovery.networkInterface = eth0
The pro-test is effective! ! !
Thanks for watching.