We've got several locations with reverse proxies setup. Our current config up and running is:

upstream backends {
    server Backend1;
    server Backend2;

server {
    ... other server config stuff here ...

    location /App1 {
        ... proxy header stuff ...

        proxy_pass http://backends/App1;

Now what we're trying to do is set it up such that the case-sensitive backends (in this case Backend1/2 http://backends/App1) can be case insensitive to the public such that you can access http://example.com/app1 OR http://example.com/App1 (or any variation of)

Our new config that we're trying to get to work is something like:

location ~* /App1 {
    proxy_pass http://backends/App1;

But no dice when we reload the config. We're seeing the error:

"proxy_pass" cannot have URI part in location given by regular expression, or inside named location, or inside "if" statement, or inside "limit_except"...

Any thoughts/insight on how we can accomplish this?


The implicit rewrite performed by proxy_pass will not work in the presence of a regular expression location. See this document for more.

However, you can use a rewrite ... break to perform the same function.

location ~* /App1(?<stuff>.*)$ {
    rewrite ^ /App1$stuff break;
    proxy_pass http://backends;

The regular expression is extended with a named capture to grab the remainder of the URI, then the rewrite statement builds a new URI for passing upstream.

See this document for details.

  • Thank you! I tried various other configs with a rewrite rule in there but with no success. Just didn't have the right combo of elements in the rule. – djneely Sep 22 '16 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.