nginx-Virtual Host

Source: Internet
Author: User

Virtual Host:
Virtual host uses special hardware and software technology, it divides a server host into a "virtual" host, each virtual host can have a separate domain name, with a complete Intemet server function (WWW, FTP, email, etc.), the same host on the virtual host is completely independent. From the site visitors, each virtual host is exactly the same as a separate host. With virtual hosts, you do not have to provide a separate Nginx server for each Web site you want to run or run a set of nginx processes separately. A virtual host provides the ability to run multiple Web sites on the same server and on the same set of nginx processes.
You can run multiple Web sites on the same server, and the sites are independent of each other.
Domain-based virtual hosting:
1. Analysis Nginx Virtual host building can be divided into based on domain name, IP, Port.
2. Modify the configuration file
server {
Listen 80;
server_name www.google.com;
Location/{
Root Html/google;
Index index.html index.htm;
}
}
server {
Listen default;
server_name www.163.com;
Location/{
Root html/163;
Index index.html index.htm;
}
}

IP-based virtual hosts:
server {
Listen 192.168.10.11:80;
server_name web.11.com;
Location/{
root/11/html;
Index index.html index.htm;
}
}
server {
Listen 192.168.10.12:80;
server_name web.12.com;
Location/{
root/12/html;
Index index.html index.htm;
}
}

Port-based virtual hosts:
server {
Listen 1111;
server_name web.11.com;
Location/{
root/11/html;
Index index.html index.htm;
}
}
server {
Listen 1212;
server_name web.11.com;
Location/{
root/12/html;
Index index.html index.htm;
}
}

nginx-Virtual Host

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.