The three most primary usage of the nginx web hosting articles based domain \ port-based \ virtual host based on IP address port

In nginx virtual hosts apache the same type and also three

1. The name-based virtual hosting

2. Port-based virtual hosts

3. Based on the IP address of the virtual host port

In nginx configuration file for each server is a virtual host if you need multiple virtual hosts only need to add the server can for example

server{

listen 80;

server_name www.lqinghua.com // name-based virtual hosting

  location / {

  root def;

  index index.html;

  }

}

server{

listen 8080; // port-based virtual hosts

server_name www.lqinghua2.com   

  location / {

  root def2;

  index index.html;

  }

}

server{

listen 192.168..0.1: 8081; // based on ip addresses and ports 

server_name www.lqinghua3.com   

  location / {

  root def2;

  index index.html;

  }

}

Guess you like

Origin www.cnblogs.com/lqinghua/p/11619719.html