nginx 80端口根据不同域名转发到不同端口

现在有一个外网服务器地址:121.42.151.190

绑定两个二级域名:

  • botao.xhope.top
  • richtech.xhop.top

这两个程序部署的端口为8080 8081
如果不使用nginx,可能需要这么访问:

问题来了,如何才能做到访问,即使不显示地加端口,也能寻找。

按照如下配置

1.安装nginx,windows下载地址http://nginx.org/en/download.html
2.配置nginx.conf

server {
        listen       80;
        server_name  botao.xhope.top;
        location / {
            proxy_pass   http://127.0.0.1:8080/;
        }
    }

server {
        listen       80;
        server_name  richtech.xhope.top;
        location / {
            proxy_pass   http://127.0.0.1:8081/;
        }
    }

3.运行nginx

nginx

4.关闭nginx

    nginx -s stop