我正在AWS ECS上设置Spring Cloud,但是Zuul / Eureka遇到问题。当我尝试点击端点“ / api / second / service2”时,我看到此错误:
我正在使用Eureka实例的Elastic IP,如此处https://github.com/Netflix/eureka/wiki/Deploying-Eureka-Servers-in-EC2所述。我有2个Spring Boot应用程序,在Eureka中都看到了它们。我可以直接击中终点。
这是Eureka服务器的配置:
server:
port: 8761
eureka:
client:
fetchRegistry: false
registerWithEureka: false
eurekaServerURLContext: eureka
region: eu-west-3
eurekaServerPort: 8761
useDnsForFetchingServiceUrls: true
eurekaServerDNSName: my.dns
datacenter: cloud
Service2:
spring:
application:
name: service2
server:
port: 8882
eureka:
datacenter: cloud
instance:
preferIpAddress: true
client:
fetchRegistry: true
eurekaServerURLContext: eureka
region: eu-west-3
eurekaServerPort: 8761
useDnsForFetchingServiceUrls: true
eurekaServerDNSName: my.dns
祖尔:
pring:
application:
name: api-gateway
server:
port: 8080
eureka:
datacenter: cloud
client:
fetchRegistry: true
eurekaServerURLContext: eureka
region: eu-west-3
eurekaServerPort: 8761
useDnsForFetchingServiceUrls: true
eurekaServerDNSName: my.dns
zuul:
prefix: /api
routes:
first-service:
path: /first/**
serviceId: service1
second-service:
path: /second/**
serviceId: service2
您是否知道问题出在哪里?
编辑: 仅当我将我的service2实例端口从8882映射到端口80时,它才起作用
答案 0 :(得分:0)
我可以看到您的service2
未在eureka中注册,例如:
eureka:
client:
registerWithEureka: true
不需要其余的配置,这些都是eureka服务器的配置,您不应该在任何服务中配置eureka服务器,它是在eureka服务本身中完成的。
它应该获取注册表,因此在service2
中您将拥有
spring:
application:
name: service2
server:
port: 8882
eureka:
client:
registerWithEureka: true
fetchRegistry: true
其余的服务都一样