I would like to know if wiremock supports multiple...
# general
j
I would like to know if wiremock supports multiple corporate proxies when we have multiple targets to proxy requests to e.g. one external domain needs proxyVia: “http://corperate.proxy1.com”, but there is another domain needs corporate proxy: “http://corperate.proxy2.com
Copy code
{
    "mappings":
    [
        {
            "request":
            {
                "urlPattern": "/api1"
            },
            "response":
            {
                "proxyBaseUrl": "<http://public.domain1.com>",
                "proxyVia": "<http://corperate.proxy1.com>"
            }
        },
        {
            "request":
            {
                "urlPattern": "/api2"
            },
            "response":
            {
                "proxyBaseUrl": "<http://public.domain2.com>",
                "proxyVia": "<http://corperate.proxy2.com>"
            }
        },
    ]
}
t
Hi @Jackie chen, WireMock doesn’t support this unfortunately as it has a single HTTP client instance and thus a single set of proxy settings. The only solution I can think of off the top of my head (short of forking WireMock and customising it in this way) is to put e.g. an nginx instance in front of it to act as a single proxy, then configure this to route to the relevant corporate proxies.
j
@Tom thank you very much for the idea. This sounds good. Let me try to understand this. 1) initialize wiremock instance with proxyVia(nginx proxy) 2) configure this nginx proxy to route requests to the desired corporate proxy Then requests will be proxied via the desired corporate proxy and sent to the external destination. Is my understanding correct?
t
Yes, that’s what I had in mind. Let me caveat - I’ve never actually tried this myself!