Nginx with IP-bound multi-domain virtual host does not work. For advice
My company has a server, IP address only one. But there are many sites on the server, how to configure, the user sent a different domain name to resolve to different directories? I read some information and wrote it, but it didn't come into effect. including location \ {} Plus also has no effect, please have a lot of shrimp advice ah.
------to solve the idea----------------------
Set up multiple servers
Set the corresponding domain name with server_name
Set up a working directory with root
As follows:
Server
{
Listen 80;
server_name www.domain1.com;
Index index.html index.htm index.php default.html default.htm default.php;
Root /home/wwwroot/web/domain1;
Location/{
rewrite xxx;
}
}
Server
{
Listen 80;
server_name www.domain2.com;
Index index.html index.htm index.php default.html default.htm default.php;
Root /home/wwwroot/web/domain2;
Location/{
rewrite xxx;
}
}
------to solve the idea----------------------
Did I understand the mistake? is not a domain name corresponding to a server? Each server has a corresponding working directory and rewrite rules
Or do you want to configure a different working directory in a server?
------to solve the idea----------------------
Do not know the level two domain name can not meet you
------to solve the idea----------------------
I do not know how you operate, I did a special test, as follows
Two servers are written before other servers are introduced, restarting Nginx
In the win's Hosts file add:
192.168.1.227www.domain1.com
192.168.1.227www.domain2.com
Create the corresponding working directory
There is a test1.html in the Test1 folder with the contents
Test1
There is a test2.html in the Test2 folder with the contents
Test2
Access
Show Test1, similarly visit http://www.domain2.com/test2.html, show Test2, explain, www.domain2.com the working directory of this domain name is test2,