1

I read and reread the nginx proxy_pass docs. I thought I understood it until I spent the last hour getting a nondescript error that doesn't make sense. Other people with the same problem don't seem related to this. Yesterday was my first day with nginx. I'm running nginx v1.12.2.

When someone requests https://example1.com/just-right/search I want to proxy that request to https://example2.com/abc.php

location ~ /just-right/search {
    proxy_pass   https://example2.com/abc.php;
}

Instead of proxying the path defined in proxy_pass I get 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" block in line .......

I'm not using a regular expression. What does 'named location' mean? It's not inside of an if statement or "limit_except" block, so what did I do wrong?

1 Answer 1

3

When you use tilde (~) in your location block, location is interpreted as a regular expression match. Remove that and it should process without error.

See documentation here: https://nginx.org/en/docs/http/ngx_http_core_module.html#location

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. The location line was 30 and the error pointed at line 31, so I was only looking at the proxy_pass line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.