URI support in proxy_pass
The nginx proxy_pass directive supports an URI:
proxy_pass http://localhost:8000/uri/;
See http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass
It would be useful to support this. This could be especially useful for custom locations, where one would want to forward without the location part. For example, with:
location /sub/ {
proxy_pass http://192.168.1.1:8080/;
}
The following forwarding would occur:
http://example.com/sub/index.html -> http://192.168.1.1:8080/index.html
Or with:
location /sub/ {
proxy_pass http://192.168.1.1:8080/other;
}
We would have:
http://example.com/sub/index.html -> http://192.168.1.1:8080/other/index.html
The former is already the case with Custom Locations released on 2.0.10. The latter could be an enhancement to that feature.
From what I see in genrated file, the proxy_pass is missing the ending slash, which makes nginx to not modify the forward URI.
I just opened this PR #99 that resolves the sub-folder forwarding. So it would look something like this: location: /api forward host: 1.1.1.1/custom-api forward port: 8080 are proxied to 1.1.1.1:8080/custom-api
Hi, Not sure where the problem is , but there is a bug in this feature.
{{ forward_path }} has same value as {{ path }} even if you provide a Forward Hostname without sub-folder. I just assume so, because I get a path not found from nginx when using it.
location /sub/ { proxy_pass http://192.168.1.1:8080/; }
That responds with a blank page.