When a user visits www.website.com I would like to server content as if the user went to www.website.com/frontend/. However, I want to mask the /frontend/ part of the url so the user doesn't see it. Can this be done?
What would my rewrite rule look like?
SOLVED:
location = / {
rewrite ^/$ /frontend/ last;
}
My issue was
location = / {} #Matches the path project.example.com only (mind there is a =)
location / {} #Matches every path (mind: there is no =)
You don't need rewrite rules for this. Just use
I don't think using
rewrite
is the perfect solution (by the way i don't think it will cover all aspects of your problem and may cause new problems)The solution is as follow:
nginx config should be something like this:
or if you are not using
sock
file, you can use http method. for example if you are running django on your localhost with port 8000, then change it to:But remember you should add this in your django
settings.py
. Unless it doesn't work at all:By this method, you are changing base url in django. so all django urls should start with
fronted
label. Now nginx can perfectly act as a reverse proxy for your site :)SOLVED:
My issue was