基于端口:
1.vim /etc/nginx/conf.d/a.conf
server {
listen 81; //端口
server_name localhost;
location / {
root /web1; //定义网站发布目录
index index.html index.htm;
}
}
server {
listen 82; //端口
server_name localhost;
location / {
root /web2; //定义网站发布目录
index index.html index.htm;
}
}
基于域名:
vim /etc/nginx/conf.d/a.conf
server {
listen 81;
server_name www.shfa.com;
location / {
root /web1;
index index.html;
}
}
server {
listen 81;
server_name www.shfb.com;
location / {
root /web2;
index index.html;
}
客户端需要做本地解析
基于ip:
临时添加IP
ip a a 192.168.200.11/24 dev ens33
ip a a 192.168.200.12/24 dev ens33
vim /etc/nginx/conf.d/a.conf
server {
listen 192.168.200.11:81;
server_name localhost;
location / {
root /web1;
index index.html;
}
}
server {
listen 192.168.200.12:81;
server_name localhost;
location / {
root /web2;
index index.html;
}
}