如何让 Spring Cloud Consul 注册到外部 IP?
How to make Spring Cloud Consul register with external IP?
如何让Spring Cloud Consul注册外网IP?
我 运行 spring 在 docker 中使用 spring 云领事启动应用程序。
该应用程序 运行 在 docker 网络中 docker 集群中。
这意味着如果 spring consul 使用主机名或 IP 地址注册,它将获得 docker 群内部的主机名或 IP 地址。我的领事服务器在 docker 集群之外。
运行 容器用-p 12345:12345 发布端口,这样你就可以从你的主机通过指定的端口访问容器
您可以在外部设置 spring.cloud.consul.discovery.ipAddress
并设置 属性 spring.cloud.consul.discovery.preferIpAddress=true
。
或者,您可以control which network interfaces从中获取 IP 地址。
在 Brixton 中您可以忽略接口:
spring:
cloud:
inetutils:
ignoredInterfaces:
- docker0
- veth.*
在 Camden(当前为 RC1)中,您还可以将网络列入白名单:
spring:
cloud:
inetutils:
preferredNetworks:
- 192.168
- 10.0
如何让Spring Cloud Consul注册外网IP?
我 运行 spring 在 docker 中使用 spring 云领事启动应用程序。 该应用程序 运行 在 docker 网络中 docker 集群中。
这意味着如果 spring consul 使用主机名或 IP 地址注册,它将获得 docker 群内部的主机名或 IP 地址。我的领事服务器在 docker 集群之外。
运行 容器用-p 12345:12345 发布端口,这样你就可以从你的主机通过指定的端口访问容器
您可以在外部设置 spring.cloud.consul.discovery.ipAddress
并设置 属性 spring.cloud.consul.discovery.preferIpAddress=true
。
或者,您可以control which network interfaces从中获取 IP 地址。
在 Brixton 中您可以忽略接口:
spring:
cloud:
inetutils:
ignoredInterfaces:
- docker0
- veth.*
在 Camden(当前为 RC1)中,您还可以将网络列入白名单:
spring:
cloud:
inetutils:
preferredNetworks:
- 192.168
- 10.0