Nginx with IP-bound multi-domain virtual host does not work. Solutions

Source: Internet
Author: User
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,
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.