You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Nginx IPv4转IPv6反向代理端口丢失问题求助

Nginx IPv4转IPv6反向代理端口丢失问题求助

大家好,我最近在配置Nginx反向代理时碰到个头疼的问题:我想让Nginx监听IPv4的8006端口(带SSL),把请求转发到一个IPv6主机的8006端口,但发现请求到达目标主机后,:8006这个端口号居然丢失了,导致服务没法正常响应。

下面是我当前的Nginx配置文件内容:

server {
    listen 8006 ssl;
    server_name gggggg.nnnnnn.com;

    ssl_certificate /home/gggg-nnnn-com/pmg-api.pem;
    ssl_certificate_key /home/gggg-nnnn-com/pmg-api.pem;

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
        proxy_set_header Xforwarded_Proto $scheme;
        proxy_pass https://ggggg6.nnnnn.com:8006/;
    }
}

为了解决这个端口丢失的问题,我已经试了几种配置,但都没起作用:

  • proxy_redirect off;
  • proxy_redirect https://ggggg6.nnnnn.com:8006/;
  • proxy_redirect default;
  • proxy_redirect ~^(https?://[^:]+):\d+(?<relpath>/.+)$ https://ggggg6.nnnnn.com:8006$relpath;

有没有大佬能帮我分析下问题出在哪,或者给个可行的解决办法?谢谢!

备注:内容来源于stack exchange,提问作者Mark-A

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.20 06:58:08