Proxy Pass based on the first field in the URI
j94305
nginx-forum at forum.nginx.org
Wed Sep 11 15:55:45 UTC 2019
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
More information about the nginx
mailing list