【发布时间】:2018-10-25 05:08:34
【问题描述】:
我正在尝试为我的 zuul 路由配置功能区,所以当我转到 http://host1:port1/restful-service/app1 时,它应该将我路由到 http://host2:port2/rest-example/app1。 当我使用“url”属性定义路由而不使用功能区时,它可以正常工作:
zuul:
routes:
restful-service:
path: /restful-service/**
url: http://host2:port2/rest-example
但是当我尝试使用功能区时,它看起来像这样:
zuul:
routes:
restful-service:
path: /restful-service/**
serviceId: restful-service
ribbon:
eureka:
enabled: false
restful-service:
ribbon:
listOfServers: host2:port2/rest-example
它只允许我路由到http://host2:port2/rest-example,但不能直接路由到所选服务http://host2:port2/rest-example/app1(它返回404状态码)。
【问题讨论】:
-
你可以写一个前置过滤器来改变请求的uri。很快就会发布示例。
标签: java spring-cloud spring-cloud-netflix netflix-ribbon