NGINX监听不同端口的配置

    server {
        listen 81;//监听的端口
        server_name localhost;//监听的域名
        location /message {//当当问这个路径时实际上会去访问下面这个地址
			proxy_pass http://localhost:xxx;//你的服务地址端口
        }
		
	   location / {//多个路径可以实现访问不同的页面
            root   D:/ddm-web;
            index  index.html;
        }
    }
server {
        listen       82 default_server;//监听82端口
		location / {//当访问localhost:82的时候,会跳转到下面的地址(页面)
			root   d:/webroot;  #path to the static files folder
            index  index.html;
        }

        location /cool {//当访问localhost:82/cool的时候,会跳转到下面的地址(页面)
		   proxy_pass http://localhost:18080/cool;
		}
	location /abc/service {//同理
		   proxy_pass http://localhost:18084/workflow/service;
        }
}

找到 nginx.conf文件,在其 中配置多个server即可,如:

想监听8080端口,则在nginx.conf配置文件中,在http{}内的末尾处,添加server即可,要添加的内容如下:

listen                 待监听的端口号;

server_name    ip地址

root                   文件路径

index                 索引文件名

80端口为默认网址,listen 80;

后server_name 网址。浏览器之间搜索网址即可,无需添加端口号

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值