0%

Nginx配置80端口转发到8080

转发效果

请求 http://www.yourdomain.com/
转发到 http://www.yourdomain.com:8080/

找到Nginx配置文件

1
[root@VM_0_11_centos ~]# find / -name nginx.conf
2
/usr/local/nginx/conf/nginx.conf
3
/etc/nginx/nginx.conf
4
/root/lnmp1.6/conf/nginx.conf
5
/root/lnmp1.6/lnmp1.6/conf/nginx.conf
6
/root/lnmp1.6/lnmp1.6/lnmp1.6/conf/nginx.conf

修改nginx配置文件

1
...
2
server{
3
       ...
4
       #...默认转发至8080端口 Satrt 
5
        location / {
6
                 proxy_pass http://localhost:8080;
7
        }
8
       #...默认转发至8080端口 End
9
        location /nginx_status
10
        {
11
            stub_status on;
12
            access_log   off;
13
        }
14
        ...
15
     }
16
...
17
}

验证配置文件是否正确

1
nginx -t

使配置文件生效

1
nginx -s reload