前言
通过nginx访问到主机的方式有两种,通过端口区分和通过域名区分。
通过端口区分主机
主机1
server {
listen 80;
server_name localhost;
location / {
root html80;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
主机2
server {
listen 81;
server_name localhost;
location / {
root html81;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}