我想以一种所有服务都在'/ gateway'上下文的方式设置zuul和底层微服务 .
例如:
微服务1有:http://localhost:8081/api/hello
微服务2有:http://localhost:8082/api/bye
我希望能够通过zuul访问微服务,如下所示:
微服务1:http://localhost:8080/ gateway / microservice1 / api / hello
微服务2:http://localhost:8080/ gateway / microservice2 / api / bye
我试图设置它,虽然看起来请求没有正确路由 .
我希望前端将所有客户端REST调用路由到以'/ gateway'开头的服务器的原因是它为前端提供了更简单的维护 .
我的application.yml:
zuul:
prefix: /gateway
routes:
microservice1:
path: /microservice1/**
serviceId: microservice1
strip-prefix: true
microservice2:
path: /microservice2/**
serviceId: microservice2
strip-prefix: true
谢谢
1 回答
试试这个配置,让我知道这是否适合你 . 我想你必须在下面定义一个全局
strip-prefix:true
. 实际上它也应该没有条带前缀工作,因为默认情况下它会删除前缀 .