Reverse proxy nginx to itself Reverse proxy nginx to itself nginx nginx

Reverse proxy nginx to itself


Just a guess.

Do you want to serve something on /?

If not - it is easy:

server{    listen       80;    server_name  localhost;        location /support/    {        alias /var/www/html/;        try_files $uri $uri/ /index.html;    }        location /    {        return 303 http://localhost/support$request_uri;    }}

Fiddle around with the ending slashes if it does not work (using them - or not - makes often a difference).

Use alias instead of root so that /support is not added to the /var/www/html folder.

Everything gets redirected to /support.


If you want to serve something on / which is different from /support:

Use sub_filter or subs_filter in /support to rewrite your source code links on-the-fly so that they will never use /.

If you have redirects inside your source code (or proxy_pass backend) - you need proxy_redirect and/or Lua to catch and change them on-the-fly.