V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
trepwq
V2EX  ›  问与答

nginx 自己经过两次 proxy_pass 会把反代的域名暴露出来?

  •  
  •   trepwq · Feb 28, 2018 · 2430 views
    This topic created in 2981 days ago, the information mentioned may be changed or developed.

    nginx 所在机器 hosts 文件写了 负载均衡 ip b.com,然后 nginx a.com proxy_pass http://b.com ,同一个 nginx b.com proxy_pass http://c.com 。访问 a.com 会跳转到 c.com ( url 直接变为 c.com )?为什么会出现这个情况?

    2 replies    2018-02-28 16:41:05 +08:00
    xmgit
        1
    xmgit  
       Feb 28, 2018
    服务器 hosts,能影响到客户端的 dns 解析?怀疑你 server 默认主机就是 c.com
    Citrus
        2
    Citrus  
       Feb 28, 2018 via iPhone
    你的代码可能检测了 Host 头。在你发的残缺的配置基础上,如果不做额外配置,c.com 的代码看到的 Host 头是 c.com 而不是 a.com 。这时候如果 c 的代码需要基于这个值做跳转,那就会出现你发的这个问题。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1025 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 22:09 · PVG 06:09 · LAX 15:09 · JFK 18:09
    ♥ Do have faith in what you're doing.