xmlf
V2EX  ›  问与答

一个神奇的 bug,苦思不得其解

  •  
  •   xmlf · Feb 21, 2022 · 1147 views
    This topic created in 1551 days ago, the information mentioned may be changed or developed.

    环境: 使用 frp 内网穿透,公网服务器端口是 1485 在公网服务器 /etc/hosts 写入 www.xxx.com 127.0.0.1

    Nginx 配置:

    location = / {
            proxy_pass          http://www.xxx.com:1485/index/index;
            proxy_set_header Accept-Encoding "";
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $host;
            proxy_set_header X-NginX-Proxy true;
            proxy_http_version 1.1;
            proxy_hide_header X-Powered-By;
            proxy_set_header Connection "upgrade";
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header X-Forwarded-Proto https;
    }
    
    location / {
            proxy_pass          http://www.xxx.com:1485;
            proxy_set_header Accept-Encoding "";
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $host;
            proxy_set_header X-NginX-Proxy true;
            proxy_http_version 1.1;
            proxy_hide_header X-Powered-By;
            proxy_set_header Connection "upgrade";
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header X-Forwarded-Proto https;
    }
    

    网站运行 https,功能一切正常。

    今天在调用微信 api 扫码登录时候,微信二维码死活不显示。

    就开始排查,最终发现是

    在 location = / 中的

    proxy_set_header X-Forwarded-Proto https;
    

    这个导致的。如果把这句注释掉,微信扫码登录二维码就能显示,否则一直在不停请求微信 api ,返回状态码 204 。

    为什么会这样??有大佬了解的吗?

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1185 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 18:06 · PVG 02:06 · LAX 11:06 · JFK 14:06
    ♥ Do have faith in what you're doing.