Nginx virtual host based on the domain name, port, IP address
Enterprise
2019-12-26 20:55:32
views: null
Article Directory
A, Nginx Web Hosting
Second, based on domain name
Third, based on the port
Fourth, based on IP address
A, Nginx Web Hosting
Each virtual web site has an independent "server {}" end configuration, each listening IP address, port number can be developed separately, of course, the site name is different.
Second, based on domain name
Preparing the environment:
The two domain names point to the same IP address
Domain: www.wang.com / www.king.com
IP address: 192.168.111.141
nginx installation has been configured in advance, and may need a fancy blog. <Nginx configuration and control of access>
1, DNS resolve
2, the contents of the configuration test page
/Usr/local/nginx/conf/nginx.conf file change, with different segments configure the server {} sites.
4, check the configuration file for syntax errors
5, access to two domain test client win10
Third, based on the port
Selection system different port, multiple ports mapped to the same IP address.
1, modify the file nginx.conf
2, restart nginx
3, the test page content
4, two access ports for testing client win10
Fourth, based on IP address
Domain: www.king.com / www.wang.com
IP address: 192.168.111.141 / 192.168.111.142
1, modify the file nginx.conf
2, restart nginx
3, dns IP address in demo
4, access to two ip address test client win10
Origin blog.51cto.com/14557584/2461876