【问题标题】:Get real ip from listener with nginx proxy使用 nginx 代理从侦听器获取真实 IP
【发布时间】:2020-07-16 06:25:49
【问题描述】:

我尝试使用 nginx 制作代理 icecast/shoutcast 广播并从侦听器获取真实 IP。

如果我输入 localhost ip

location /exampleradio/ {
    proxy_buffering           off;
    proxy_ignore_client_abort off;
    proxy_intercept_errors    on;
    proxy_next_upstream       error timeout invalid_header;
    proxy_redirect            off;
    proxy_connect_timeout     60;
    proxy_send_timeout        21600;
    proxy_read_timeout        21600;

    proxy_set_header Host 127.0.0.1:8000;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;

    proxy_pass http://127.0.0.1:8000;
}

正确显示的监听器ip,

当我从另一个服务器示例中放置另一个收音机时:

location /exampleradio1/ {
    proxy_buffering           off;
    proxy_ignore_client_abort off;
    proxy_intercept_errors    on;
    proxy_next_upstream       error timeout invalid_header;
    proxy_redirect            off;
    proxy_connect_timeout     60;
    proxy_send_timeout        21600;
    proxy_read_timeout        21600;

    proxy_set_header Host cast.example.com:8000;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;

    proxy_pass http://cast.example.com:8000;
}

另一台服务器上的侦听器 ip 它显示 服务器 ip 并且没有 侦听器 ip。 我该如何解决这个问题并获得监听器 ip 而没有服务器 ip?

谢谢。

【问题讨论】:

    标签: nginx proxy icecast shoutcast internet-radio


    【解决方案1】:

    唯一支持“X-Forwarded-For”标头的服务器是 Icecast-kh。

    切换到 Icecast-kh,保持 Nginx 配置不变,不要忘记添加

    <x-forwarded-for>_PROXY IP HERE_</x-forwarded-for>

    到你的 Icecast-kh 配置。

    【讨论】:

    • 更好的是,一开始就抛弃 Nginx。
    • 我正在寻找相同问题的解决方案。就我而言,我通过Traefik,它或多或少与我之前测试过的 Nginx 相同。 Icecast-KH 包的基本文件icecast.xml 中不存在<x-forwarded-for> 配置。您在哪里找到这些信息?
    • 这是我 10 天以来搜索的解决方案!恭喜并万分感谢!效果很好issues/195
    猜你喜欢
    • 1970-01-01
    • 2020-05-31
    • 2020-10-21
    • 2011-07-22
    • 1970-01-01
    • 1970-01-01
    • 2018-05-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多