How to get nginx to redirect to another path only if the root path is requested?

leeand00 nginx-forum at forum.nginx.org
Sun Jan 28 02:36:44 UTC 2018


I have other subfolders in my location paths so for instance other than just
/ after my host, I also have /lang/english/grammar, and
/lang/spanish/gramática

But I figured it out:

        location = / {
               resolver 127.0.0.1 valid=300s;
     	       proxy_pass http://192.168.1.200:8080/;
               proxy_set_header X-Forwarded-Host $host;
	       proxy_set_header X-Forwarded-Server $host;
               proxy_set_header X-Real-IP $remote_addr;
               proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	       rewrite /(.*) /$1 break;
	       access_log ./logs/root_access.log;
               error_log ./logs/root_error.log;
        }

The = / that you suggested fixed it right up, thanks!

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,278283,278289#msg-278289



More information about the nginx mailing list