azure - Nginx 无法代理端口
问题描述
我使用 Nginx 作为负载均衡器。它能够将请求路由到指定的主机地址,但不能路由到上游块中提到的端口。它总是将它发送到默认端口。
我尝试了多种方法来修改proxy_set_header Host
, proxy_set_header X-Forwarded-For
, proxy_set_header X-Real-IP
,proxy_set_header X-Forwarded-Proto
等proxy_set_header Referer
。但似乎没有任何效果。
我在 Azure 中安装了 Nginx 服务器,并尝试访问同一虚拟网络中的 VM。
预期行为: http://localhost/sites -----> http://zzz:9081/sites(应考虑 IP:Port) 实际行为: http://localhost/sites -----> http://zzz/sites(需要IP,但端口是80/默认监听端口)。
upstream alb {
ip_hash;
server zzz:9081;
server zzz:9080;
}
server {
listen 80;
server_name localhost;
# root /usr/share/nginx/html;
location /sites {
proxy_pass http://alb/sites;
proxy_set_header X-Real-IP $remote_addr;
}
}
任何帮助将不胜感激。
解决方案
推荐阅读
- frontend - GoogleCreativeContainerClass 来自哪里?
- transactions - 从密码学的角度需要有关付款如何工作(授权结算清算)的资源和建议
- java - AWS lambda/api 网关不重定向
- node.js - 猫鼬不查询
- facebook - 请求 user_friends
- reactjs - 使用 TypeScript 在 React 中导出颜色
- javascript - 计算最后一个工作页面以进行抓取的最快方法
- echarts - 图表。如何更新实时图表中的两个系列?
- spring-session - 将通用 redis 代码转换为 Azure Redis 缓存
- swift - 无法在 xcode 9.2 中拖放对象