A site is configured with multiple domain names.
server { listen 80; server_name ops-coffee.cn b.ops-coffee.cn ; }
Server_name can be followed by multiple domain names, which are separated by spaces.
A service configures multiple sites.
server { listen 80; server_name a.ops-coffee.cn ; location / { root /home/project/pa; index index.html ; } } server { listen 80; server_name ops-coffee.cn b.ops-coffee.cn ; location / { root /home/project/pb; index index.html ; } } server { listen 80; server_name c.ops-coffee.cn ; location / { root /home/project/pc; index index.html ; } }
Based on Nginx virtual host configuration, Nginx has three types of virtual hosts.
IP-based virtual host: You need multiple addresses on your server, and each site corresponds to a different address. This method is rarely used.
Port-based virtual host: each site corresponds to a different port. When accessing, use ip:port, and you can modify the port of listen to use it.
Domain name-based virtual host: the most widely used way is to use the domain name-based virtual host in the above example, provided that you have multiple domain names corresponding to each site, and server_name can fill in different domain names.
Copyright Description:No reproduction without permission。
Knowledge sharing community for developers。
Let more developers benefit from it。
Help developers share knowledge through the Internet。
Follow us