nginx-proxy-manager icon indicating copy to clipboard operation
nginx-proxy-manager copied to clipboard

URI support in proxy_pass

Open jlesage opened this issue 7 years ago • 5 comments

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

jlesage avatar Mar 07 '19 02:03 jlesage

The former is already the case with Custom Locations released on 2.0.10. The latter could be an enhancement to that feature.

jc21 avatar Mar 07 '19 04:03 jc21

From what I see in genrated file, the proxy_pass is missing the ending slash, which makes nginx to not modify the forward URI.

jlesage avatar Mar 07 '19 10:03 jlesage

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

kolbii avatar Mar 10 '19 10:03 kolbii

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.

briscula avatar Nov 16 '19 00:11 briscula

location /sub/ { proxy_pass http://192.168.1.1:8080/; }

That responds with a blank page.

blade10101 avatar Dec 25 '23 05:12 blade10101