【发布时间】:2019-08-22 05:31:49
【问题描述】:
我想用 nginx 监听端口并设置代理。
这是服务器的配置文件
server{
listen 8080;
location / {
proxy_pass http://127.0.0.1:82;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-live;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
server{
listen 8081;
location / {
proxy_pass http://127.0.0.1:83;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-live;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
8080可以,但是8081连接不上
【问题讨论】:
-
如果您只想将 8080 映射到 82 和 8081 到 83,使用 IPtables 会更简单 - 否则您必须将域名分配给不同的
server部分(例如server_name one.test.com;和server_name two.test.com)并将这些域名映射到nginX服务器的IP地址。
标签: nginx