Problem:
- I use a nginx
proxy_pass
directive to redirecthttps
requests with a specificlocation
path in the URI, e.g.,https://domain/path/index.html
tohttp://container_ip:port/index.html
. - This works fine for the initial request.
- However, if the HTML-file specifies resources to load, clients search these resources without the path, using only the base URL; in the example
https://domain/main.css
.
Question:
How can I configure nginx so that such resources also are searched at the original path; in the example at https://domain/path/main.css
?
Current incorrect nginx configuration:
server {
listen 443 ssl;
server_name domain;
[...]
location /path/ {
proxy_set_header Host $host;
proxy_pass http://container_ip:port/;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-For $remote_addr;
}
}