Comment on nginx reverse proxy using subpaths help
CameronDev@programming.dev 1 year ago
This is part of my config that does something similar, hopefully it helps?:
location /dynmap { rewrite ^/dynmap/(.*) /$1 break; proxy_pass http://192.168.1.100:8123/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host$uri; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-NginX-Proxy true; proxy_cache_key "$host$uri"; proxy_cache_valid 200 302 60m; proxy_cache_valid 404 10m; proxy_cache_use_stale error timeout invalid_header updating http_500 http_503 http_504; proxy_connect_timeout 10; index index.html index.htm; } location /bluemap { rewrite ^/bluemap/(.*) /$1 break; proxy_pass http://192.168.1.100:8100/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host$uri; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-NginX-Proxy true; proxy_cache_key "$host$uri"; proxy_cache_valid 200 302 60m; proxy_cache_valid 404 10m; proxy_cache_use_stale error timeout invalid_header updating http_500 http_503 http_504; proxy_connect_timeout 10; index index.html index.htm; }
SpaceCadet@sopuli.xyz 1 year ago
Hmm no, that’s not really it… that’s more so that you don’t pass URLs starting with
/app1/
onwards to the application, which would not be aware of that subpath.I think I need something that intercepts the content being served to the client, and inserts
/app1/
into all hardcoded absolute paths.For example, let’s say on app1’s root I have an index.html that says:
It should be dynamically served as: