Reputation: 828
I am trying to pass captured regex group as URI.
Config:
location ~ /proxy/(.*?)$ {
proxy_pass http://$1;
}
Needed:
http://127.0.0.1:9999/proxy/example.com/test/asd.html
should proxy pass to:
http://example.com/test/asd.html
Result:
> curl http://127.0.0.1:9999/proxy/example.com/test/asd.html
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
The error log is empty.
What am I missing here? Thanks
Upvotes: 1
Views: 1063
Reputation: 1794
I tried looking up NGINX location regex to see how the regex object works (that is // in JS) and here is what you should try
location ~ \/proxy\/(.*?)$ {
proxy_pass http://$1;
}
see if that helps
Upvotes: 1