Search code examples
apacheubuntuproxymod-proxyproxypass

ProxyPass Exclude path


i configured an apache proxy to forward all calls to another web server. I need to exclude the path http://my-server/{var1}/api/{all-path} (where var1 is variable) from this rule.

How can I do?

Thanks

I tried with:

ProxyPassMatch ^/(.*)/api/(.*)$ !
ProxyPass / http://127.0.0.1:8080/

but not working.


Solution

  • I'd say you need a negative lookahead in your matching pattern and only a single proxy directive:

    ProxyPassMatch ^/[^/]+/(?!api/) http://127.0.0.1:8080/
    

    That should match any path starting with something and a following slash, followed by anything that is NOT "api/".