I'm trying to proxy pass a location excluding only a casistic with a regex.
I have this url /autocomplete/<var1>/<var2>
and I want to proxy pass only if var1
is different from a
, so b/foo
, c/foo
ecc will be proxied.
In apache I used this:
ProxyPassMatch ^/autocomplete/a/(.*)$ !
ProxyPass /autocomplete/ http://localhost:1234/autocomplete/
In NGINX I tried with this:
location ~ /autocomplete/(?<var1>.*)/(?<var2>.*) {
if ($var1 != "a") {
proxy_pass http://127.0.0.1:1234/autocomplete/$var1/$var2;
}
}
It works for other values of var1
, but for a
it returns 404.