Proxy Pass based on the first field in the URI

meir hazon meir.hazon at ev-box.com
Wed Sep 11 18:42:21 UTC 2019


Hi,

It looks great, I will try it out and let you know.

Thanks so much,

Meir

On Wed, Sep 11, 2019 at 5:56 PM j94305 <nginx-forum at forum.nginx.org> wrote:

> Try something like this:
>
> map $urlprefix $urlproxy {
>   "foo" "https://foohost.foo.com";
>   "bar" "http://barhost.blah.com";
>   "fie" "https://fie.special.domain.com/blubb";
>   default "https://standard.com";
> }
>
> [...]
>
> location ~ "^/(?<urlprefix>[^/]+)(?<urlsuffix>/.*)$" {
>
>   [...]
>   proxy_pass "$urlproxy$urlsuffix$is_args$args";
>   [...]
> }
>
> You can dynamically determine the host (including a URL piece, if
> necessary)
> with the "map", and use the mapped proxy prefix then in the proxy_pass
> directive. If whatever lies beyond the NGINX requires URL arguments, don't
> forget the $is_args$args part.
>
> --j.
>
> Posted at Nginx Forum:
> https://forum.nginx.org/read.php?2,285607,285609#msg-285609
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20190911/80b44455/attachment.htm>


More information about the nginx mailing list