【发布时间】:2021-01-30 17:23:23
【问题描述】:
我们目前的项目要求是将一些请求路由到第三方外部 api 服务器。为此,我们使用基于 spring zuul 的路由器服务。
zuul:
routes
test:
path: /test/**
serviceId: test
url: http://my.api.server.com
test2:
path: /test2/**
serviceId: test2
url: http://my.api.server.com // but through an external proxy
现在的要求是,对于某些端点,对外部 api 服务器的请求已经通过一些外部代理服务器路由,而不是我们拥有的,
如何通过 curl 做到这一点是:
curl <external_api_server>/api/v1/user -k \
-x tntqyhnhjym.sandbox.verygoodproxy.com:8080 \
-H "Content-type: application/json" \
-d '{"card_number": "tok_sandbox_t8VSoovCuHA779eJGZhKvg", ... }'
-x <proxy> 通过给定的代理重定向请求。
如何通过 spring-zuul 服务器做到这一点?
有一个线索,我得到了? https://github.com/spring-cloud/spring-cloud-netflix/issues/2320。不干净,在某种意义上我需要扩展SimpleHostRoutingFilter 的zuul
【问题讨论】:
-
Service
serviceId: test2是您的微服务之一,您想将 test2 的请求转发到外部服务器是吗?如果是,我们可能会创建 pre 类型的过滤器,以将请求转发到外部服务器的/test2/**端点,让我知道您对此的想法 -
@PatelRomil,
test2是我的微服务之一,我想将请求转发到我的api服务器(不是外部服务器),但条件是我想通过路由请求代理服务器。见例子hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/…
标签: spring-boot proxy netflix-zuul