简体   繁体   中英

Get real ip from listener with nginx proxy

I try to make proxy icecast/shoutcast radio with nginx and get real ip from listener.

If i put 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;
}

the listener ip it shows correctly,

When i put another radio from another server example:

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;
}

the listener ip on another server it shows the server ip and no listener ip . How can i solve this and get listener ip and no server ip?

Thanks.

The only server that supports "X-Forwarded-For" header is Icecast-kh.

Switch to Icecast-kh, leave your Nginx config as is and don't forget to add

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

to your Icecast-kh config.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM