一 基于域名
server {
listen 80;
server_name www.google.com;
location / {
root html/google;
index index.html index.htm;
}
}
server {
listen 80 default; #default 在浏览器中直接输入IP地址会进入这个
server_name www.163.com;
location / {
root html/163; #发布目录在html下的163目录
index index.html index.htm;
}
}
二 基于IP
server {
listen 192.168.198.131:80;
location / {
root /11/html;
index index.html index.htm;
}
}
server {
listen 192.168.198.132:80;
location / {
root /12/html;
index index.html index.htm;
}
}
三 基于端口
server {
listen 1111;
location / {
root /11/html;
index index.html index.htm;
}
}
server {
listen 1212;
location / {
root /12/html;
index index.html index.htm;
}
}