Our current project requirement is to to route some requests to third-party external api servers. For this we are using spring zuul based router service.
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
Now the requirement is that for some endpoints, the requests to the external api server has be routed through some external proxy server, not owned by us,
How to do this via a curl is:
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>
redirects the request through the given proxy.
How to do this via spring-zuul server?
There is one lead, I have gotten? https://github.com/spring-cloud/spring-cloud-netflix/issues/2320. Not clean, in the sense that I would need to extendSimpleHostRoutingFilter
of zuul
serviceId: test2
is one of the microservice of yours and you want to forward the request of test2 to an external server Is it? If yes, we may create the filter of pre type to forward requests to the external server for the/test2/**
endpoints, Let me know your thoughts on the same – Luanatest2
is one of my microservice, and I want to forward the request to my api server(not the external server), but the condition is that I want to route the request through a proxy server. see example hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/… – Dentalium