Speaking in front of how to configure IP-based virtual hosting, you can go here to see nginx series: https://www.cnblogs.com/zhangweizhong/category/1529997.html
Based on today to say something about how Nginx virtual host ports.
Scenarios
Foreign nginx provides two ports 81 and 82 listening service.
Html port 81 in the request directory is requested html81
Html port 82 in the request directory is requested html82
Preparing the environment
1. Create 192.168.78.132 virtual machines and virtual networks to ensure smooth local computer.
2. Install nginx on 192.168.78.132.
html directory creation
Nginx original copy of html directory two directories html81 and html82, in order to facilitate testing index.html need to modify the contents of each directory to make it personalized.
Virtual Host Configuration
Modify /usr/local/nginx/conf/nginx.conf file, add two virtual hosts, as follows: vi /usr/local/nginx/conf/nginx.conf
the nobody #user; worker_processes . 1 ; Events { worker_connections 1024 ; } HTTP { the include the mime.types; default_type file application / OCTET - Uninterpreted Stream; the sendfile ON; keepalive_timeout 65 ; # Virtual Host Configuration Server { # listening ip and port configuration 80 the listen 80 ; # virtual host name here ip address configuration server_name 192.168 . 101.3 ; # all requests to / start, all requests can be matched this LOCATION LOCATION /{ # Using directive specifies the virtual host root directory that is web storage directory # such as access to HTTP: // ip / test.html will find /usr/local/html3/test.html # such as access to HTTP: // ip / Item / the Test. html will find /usr/local/html3/item/test.html root / usr / local / nginx / html80; # specify the welcome page and look left to right order index index.html index.htm; } } # configure virtual host Server { the listen 8080 ; server_name 192.168 . 101.3 ; LOCATION / { the root / usr / local / Nginx /html8080; index index.html index.htm; } } }
test
Nginx reload configuration profiles, view the port status monitor:
Access http://192.168.78.132:81
Access http://192.168.78.132:82
At last
Or more, put nginx finished based on the configuration of the virtual hosts ip. Behind will continue to speak to configure name-based virtual hosts.