Welcome! Log In Create A New Profile

Advanced

General /etc/nginx/vhosts/default - how to specify server wide settings

Posted by CrazyDogster 
General /etc/nginx/vhosts/default - how to specify server wide settings
May 12, 2011 01:42AM
Hey guys.

From what I see if I write in the /etc/nginx/vhosts/default the effect will be server wide contrary to per domain confs. I can't seem to know how to write a rule to redirect from /index.html or /dir/index.html ro / or /dir/ to have server wide effects.

The thing is that running on CentOS makes files in /home/user/public_html and from nginx I can't see the user part to use it in the root directive. I thought of something like this:

---
server
{
listen 111.111.111.111:80; // fake IP
server_name ""; // this to take in all hosts... not sure if this is the right way to go..
root ~^/home/(.*)/public_html // this (.*) would contain the user part
rewrite ^(.*/)index.(html|htm) http://$host$1 permanent;
}
---

As you can see.. probably.. I'm trying to make that redirect work for all sites without having to manually edit each specific per domain conf file.

Any help is much appreciated :)

Thank you
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 300
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready