Answer the question
In order to leave comments, you need to log in
Location in NGINX?
I've been suffering for 3 days, I tried different options - all in vain. The last hope is for you)
How to implement locations in nginx like this:
mysite.com -> /var/www/main
mysite.com/любой_текст -> /var/www/qwerty
server {
root /var/www/qwerty;
location = / {
root /var/www/main;
rewrite ^ /index.html break;
}
}
Answer the question
In order to leave comments, you need to log in
Judging by the comments, nothing works for you because you need the index.html file, not just /var/www/main and you forgot that the index module does an internal redirect.
This is how it should work:
server {
root /var/www/qwerty;
location = / {
root /var/www/main;
rewrite ^ /index.html break;
}
location = / {root /var/www/main;}
location / {root /var/www/qwerty;}
I don’t even remember, somewhere I saw among the software for monitoring the setting of hosts, rights and other nginx configs through the browser.
Check out pcp.io or munin . In general, nginx configs can be easily generated by yourself, just take a sample from /etc/nginx and put everything in /etc/nginx/conf.d.
And after all the changes service nginx restart
.
The script for bash is elementary, you can throw it in an hour using only sed and perl or even on awk, it will work no worse than Denver.
location = / {
root /var/www/main;
try_files /index.html =404;
}
location / {
/var/www/qwerty;
try_files /index.html =404;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question