Skip to content

URI support in proxy_pass #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jlesage opened this issue Mar 7, 2019 · 5 comments
Closed

URI support in proxy_pass #98

jlesage opened this issue Mar 7, 2019 · 5 comments

Comments

@jlesage
Copy link
Contributor

jlesage commented Mar 7, 2019

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

@jc21
Copy link
Member

jc21 commented Mar 7, 2019

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

@jlesage
Copy link
Contributor Author

jlesage commented Mar 7, 2019

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

kolbii added a commit to kolbii/nginx-proxy-manager that referenced this issue Mar 10, 2019
@kolbii
Copy link
Contributor

kolbii commented Mar 10, 2019

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

@jc21 jc21 closed this as completed in d79fcbf Mar 15, 2019
@briscula
Copy link

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.

@blade10101
Copy link

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

That responds with a blank page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants