NGINX根据不同域名请求跳转同一台机器的不同项目

1.实验环境及目的

CentOS Linux release 7.4.1708 (Core)

nginx 1.12.1

aa.xiaowenxiao.xin、bb.xiaowenxiao.xin都解析到140.143.152.14(默认80端口)

实现访问域名aa.xiaowenxiao.xin跳转140.143.152.14:81

实现访问域名bb.xiaowenxiao.xin跳转140.143.152.14:82

2.安装nginx

https://blog.csdn.net/Jenson_/article/details/77896608

3.修改nginx.conf

   server {
        listen       80;
        server_name  aa.xiaowenxiao.xin;
    location / {
            proxy_pass http://140.143.152.14:81;
        }
}


    server {
        listen       80;
        server_name  bb.xiaowenxiao.xin;
        location / {
            proxy_pass http://140.143.152.14:82;
        }

4.实验结果

猜你喜欢

转载自www.cnblogs.com/killall007/p/9099346.html