Nginx virtual host based on the domain name, port, IP address

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

Nginx virtual host based on the domain name, port, IP address

Nginx virtual host based on the domain name, port, IP address

Nginx virtual host based on the domain name, port, IP address

Nginx virtual host based on the domain name, port, IP address

Nginx virtual host based on the domain name, port, IP address

Nginx virtual host based on the domain name, port, IP address

Nginx virtual host based on the domain name, port, IP address

Nginx virtual host based on the domain name, port, IP address

2, the contents of the configuration test page

Nginx virtual host based on the domain name, port, IP address

Nginx virtual host based on the domain name, port, IP address

/Usr/local/nginx/conf/nginx.conf file change, with different segments configure the server {} sites.

Nginx virtual host based on the domain name, port, IP address
Nginx virtual host based on the domain name, port, IP address

4, check the configuration file for syntax errors

Nginx virtual host based on the domain name, port, IP address

5, access to two domain test client win10

Nginx virtual host based on the domain name, port, IP address

Nginx virtual host based on the domain name, port, IP address

Nginx virtual host based on the domain name, port, IP address

Third, based on the port

Selection system different port, multiple ports mapped to the same IP address.

1, modify the file nginx.conf

Nginx virtual host based on the domain name, port, IP address

Nginx virtual host based on the domain name, port, IP address

2, restart nginx

Nginx virtual host based on the domain name, port, IP address

3, the test page content

Nginx virtual host based on the domain name, port, IP address

4, two access ports for testing client win10

Nginx virtual host based on the domain name, port, IP address

Nginx virtual host based on the domain name, port, IP address

Fourth, based on IP address

Domain: www.king.com / www.wang.com

IP address: 192.168.111.141 / 192.168.111.142

Nginx virtual host based on the domain name, port, IP address

1, modify the file nginx.conf

Nginx virtual host based on the domain name, port, IP address
Nginx virtual host based on the domain name, port, IP address

2, restart nginx

Nginx virtual host based on the domain name, port, IP address

3, dns IP address in demo

Nginx virtual host based on the domain name, port, IP address
Nginx virtual host based on the domain name, port, IP address
Nginx virtual host based on the domain name, port, IP address

4, access to two ip address test client win10

Nginx virtual host based on the domain name, port, IP address

Nginx virtual host based on the domain name, port, IP address

Nginx virtual host based on the domain name, port, IP address

Guess you like

Origin blog.51cto.com/14557584/2461876