我想以一种所有服务都在' / gateway'之下的方式设置zuul和底层微服务。上下文。
例如:
微服务1具有:http://localhost:8081/api/hello
微服务2具有:http://localhost:8082/api/bye
我希望能够通过zuul访问微服务,如下所示:
微服务1:http://localhost:8080/ 网关 / microservice1 / api / hello
微服务2:http://localhost:8080/ 网关 / 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
谢谢
答案 0 :(得分:2)
试试这个配置,让我知道这是否适合你。我想你必须在下面定义一个全局strip-prefix:true
。实际上它也应该没有条带前缀,因为默认情况下它会删除前缀。
zuul:
prefix: /gateway
strip-prefix: true
routes:
microservice1:
path: /microservice1/**
serviceId: microservice1
strip-prefix: true
microservice2:
path: /microservice2/**
serviceId: microservice2
strip-prefix: true