V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
Vickies
V2EX  ›  NGINX

关于 nginx 配置转发的问题。

  •  
  •   Vickies · 7 天前 · 861 次点击
    访问地址 https://qwzqhd.csgmall.com.cn/csg/reciprocal/common/user/queryBindingEleUsers
    通过 curl 是可以正常返回数据的。
    后面我将另一个域名( searchxq.com )通过 nginx 代理转发。配置如下:
    location /csg/reciprocal/{
    proxy_pass https://qwzqhd.csgmall.com.cn/csg/reciprocal/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }


    reload 后访问 https://searchxq.com/csg/reciprocal/common/user/queryBindingEleUsers 什么数据都没有返回。请问是我配置错误了么?
    5 条回复    2025-02-13 11:15:49 +08:00
    KIMI360
        1
    KIMI360  
       7 天前
    这样配是不是转发后的路径/csg/reciprocal/会出现两次,改成 proxy_pass https://qwzqhd.csgmall.com.cn/试试
    xxiu
        2
    xxiu  
       7 天前   ❤️ 1
    proxy_set_header Host $host; 修改成 proxy_set_header Host qwzqhd.csgmall.com.cn; 试试
    Vickies
        3
    Vickies  
    OP
       7 天前
    @xxiu 这个可以,感谢~
    xxiu
        4
    xxiu  
       7 天前
    你转发的后端也应该是一个 nginx 之类的 需要传递正确的 host ,保证 https 的 sni 是对的。
    Vickies
        5
    Vickies  
    OP
       7 天前
    @xxiu 是的。懂了,谢谢~
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1050 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 19:11 · PVG 03:11 · LAX 11:11 · JFK 14:11
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.