Linux Nginx 一台服务器2个站点共用80端口

jackadmi 2020-05-07

修改default.conf 文件如下:

server {   --站点1
    listen 80;
    server_name  txy.vcgo.vip;  --站点域名
    location / {
        proxy_pass http://111.229.75.253:5000;  --站点端口 http://localhost:5000 也可以用localhost
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection keep-alive;
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}
server {  --站点2
    listen 80;
    server_name  f.vcgo.vip;  --站点域名
    location / {
       proxy_pass http://111.229.75.253:8081;   --站点端口  
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection keep-alive;
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}
$ nginx -s reload   --执行命令使其即时生效 ,如果命令失败,多半是修改文件里面有语法错误

相关推荐

lwplvx / 0评论 2020-11-22
岁月如歌 / 0评论 2020-07-21