【发布时间】:2019-08-18 02:05:47
【问题描述】:
我在 Heroku 上有几个微服务 - eureka-server、Zuul 服务器和一些应用服务。
当我尝试通过 Zuul 网关访问我的任何服务时,例如“service1”,Zuul 无法将请求转发到相应的服务(当我尝试在本地运行它们时一切正常)。 我在 Zuul 日志中发现了以下错误:
com.netflix.zuul.exception.ZuulException: Forwarding error
Caused by: com.netflix.client.ClientException: Load balancer does not have the available server for the client: service1
以下是我的服务配置:
1) “zuul 服务器”application.yml
server:
port: ${PORT:8000}
zuul:
prefix: /api
ignoredServices: '*'
routes:
service1:
path: /path_for_service1/**
serviceId: service1
strip-prefix: false
...
management:
endpoints:
web:
exposure:
include: "*"
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_URL:http://localhost:5000}/eureka/
2)“尤里卡服务器”application.yml
server:
port: ${PORT:5000}
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
3.1) "service1" application.yml
server.port=${PORT:8081}
eureka.client.service-url.defaultZone=${EUREKA_URL:http://localhost:5000}/eureka/
3.2) "service1" bootstrap.yml
spring:
application:
name: service1
所有微服务都在 eureka 仪表板中可见。
如果我将 zuul 路由更改为硬编码的 url,它运行良好,但它不是我想要的。
zuul:
prefix: /api
ignoredServices: '*'
routes:
service1:
path: /path_for_service1/**
url: http://url_of_service_1
strip-prefix: false
你能帮我解决这个问题吗?
【问题讨论】:
标签: spring-boot heroku netflix-eureka netflix-zuul netflix-ribbon