Nginx redirects static files to subdir of root Nginx redirects static files to subdir of root nginx nginx

Nginx redirects static files to subdir of root


From what I understand, you have a working configuration and the only problem is that you would like the URL http://myapp.mydomain.com/ to be mapped to http://192.168.0.2:8080/web/.

Your working configuration is:

server {  listen       80;  server_name  myapp.mydomain.com;  satisfy any;  location / {    proxy_pass  http://192.168.0.2:8080/;    index  index.html index.htm;  }}

The simplest solution is to add an exact match for the / URI. Such as:

server {  listen       80;  server_name  myapp.mydomain.com;  satisfy any;  location = / { rewrite ^ /web/; }  location / {    proxy_pass  http://192.168.0.2:8080/;    index  index.html index.htm;  }}