'How to pass nginx proxy_pass path to upstream server
I have configured nginx as below
location /path {
proxy_pass https://127.0.0.1:4000/;
}
When I open the website, https://myserver.com/path --> https://127.0.0.1:4000 But all the Hyperlinks inside https://myserver.com/path site are marked are myserver.com/some.php So I am in page https://myserver.com/path but any link/URL I click goes to https://myserver.com/some.php which should actually be https://myserver.com/path/some.php
I am not sure how to do this. I have tried removing trailing "/" after 127.0.0.1:4000 but it gives 404 Not found error.
Another issue am facing is, When I open 127.0.0.1:4000 on browser, I can see website loads properly. But nginx proxy shows a weird page which doesn't load CSS/any Images. I have tried multiple directives to add to configuration to get CSS/Images
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
add_header Pragma "no-cache";
add_header Cache-Control "no-cache";
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
