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