Skip to content

Nginx proxy_pass issue caused by upstream variable #1515

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
p-fruck opened this issue Oct 24, 2021 · 1 comment · Fixed by #1519
Closed

Nginx proxy_pass issue caused by upstream variable #1515

p-fruck opened this issue Oct 24, 2021 · 1 comment · Fixed by #1519
Labels

Comments

@p-fruck
Copy link

p-fruck commented Oct 24, 2021

Checklist

  • Have you pulled and found the error with jc21/nginx-proxy-manager:latest docker image?
    • Yes
  • Are you sure you're not using someone else's docker image?
    • Yes
  • Have you searched for similar issues (both open and closed)?
    • Yes

Describe the bug

While reading through #1462 I suspected the issue to be a misconfiguration, which wasn't related to the nginx proxy manager. Since I use a similar setup, I posted my solution. Afterwards, I updated my exact same solution just to realize, that it doesn't work anymore. My setup is as follows:

english.website -> static_container:80/en/
german.website -> static_container:80/de/

I achieved this using a custom location for /. This setup was working a few versions back (I don't remember the exact version), and does work again if I update the generated nginx configs manually to revert the commit 6c1ae77#diff-d59b1035c588d4d81d509bb6c436f753aa5256a9cada91f28b6afc55b26d2c6b

To be even more precise, I simply changed

set           $upstream http://static_container:80/en/;
proxy_pass    $upstream;

to

proxy_pass    http://static_container:80/en/

Nginx Proxy Manager Version

v2.9.9

To Reproduce
Steps to reproduce the behavior:

  1. Add a new proxy host, e.g. my.domain. Forward name and port don't matter as they will be overwritten.

  2. Add a custom location as shown in the below picture. You have to adapt the container name
    image

  3. Save the proxy host and access it. Enter a url that doesn't even exist on the server, like my.domain/doesnotexist, and realize that static_container/en/index.html is returned for this path as well as for every other path. This also replaces all css and js files with the index html.

  4. Adapt the generated nginx config file manually. Change proxy_pass $upstream to proxy_pass http://static_container:80/en/ (which is the same value as assigned to $upstream).

  5. Disable an re-enable the proxy host to reload the configuration. Now my.domain/doesnotexist results in a 404 error as it should, and js and css files for static_container/en/index.html are fetched correctly.

Expected behavior

It should work, as it used to with the previous version.

Operating System

Linux, not applicable for this issue

Additional context

While troubleshooting, I also stumbled upon this stackoverflow thread, which looks really promising

@p-fruck p-fruck added the bug label Oct 24, 2021
@chaptergy
Copy link
Collaborator

If I remember correctly using a variable inside proxy_pass instead of a string literal changes how nginx processes the url. If it is a string literal it will append the path after the location, so location /foo/ with a proxy_pass of 1.2.3.4/test and a request to /foo/bar/ will result in a proxy request to 1.2.3.4/test/bar. But when a variable is used, nginx expects the full path in the variable and will not append anything, resulting in all requests being proxied to 1.2.3.4/test without any other data from the path being used.

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

Successfully merging a pull request may close this issue.

2 participants