Reputation: 19
location / {
set $stream_username $host;
if ($host ~* "^([A-Za-z0-9_]+)\.test\.example\.com$") {
set $stream_username $1;
}
proxy_pass http://127.0.0.1:2198/proxy-redirect/$stream_username;
proxy_set_header X-MountPoint $uri;
proxy_redirect off;
proxy_connect_timeout 8;
proxy_read_timeout 15;
proxy_send_timeout 15;
proxy_max_temp_file_size 0;
}
location ~ ^/streamproxy/(.*)$ {
internal;
set $stream_url http://$1;
proxy_buffering off;
proxy_ignore_client_abort off;
proxy_intercept_errors off;
proxy_next_upstream error timeout invalid_header;
proxy_redirect off;
proxy_set_header User-Agent "$http_user_agent [ip:$remote_addr]";
proxy_set_header X-Forwarded-For $remote_addr;
proxy_connect_timeout 8;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_max_temp_file_size 0;
proxy_pass $stream_url$is_args$args;
}
HTTP/1.0 200 OK
Content-Length: 8
Connection: close
X-Accel-Buffering: no
X-Accel-Expires: off
X-Accel-Redirect: /streamproxy/ip:port
when you enter the shoutcast page, that is, your ip:port, shoutcast comes up first, that is, ip:port/index.html?sid=1, so if the proxy_pass is http://127.0.0.1:2198/proxy-redirect/$stream_username; which when executed call X-Accel-Redirect and brings the radio's ip:port, if the proxy pass reads the ip:port correctly, the shoutcast page comes up first, http://webradio.test.example.com/index.html?sid=1, but it does not appear because the browser says ERR_TOO_MANY_REDIRECTS and the shoutcast page does not appear correctly, while when the radio is icecast, the page appears correctly in the browser without any errors. Why ?
Update
location ~ ^/streamproxy/(.*)$ {
internal;
set $stream_url http://$1;
proxy_buffering off;
proxy_ignore_client_abort off;
proxy_intercept_errors on; # Enable error interception
proxy_next_upstream error timeout invalid_header;
proxy_redirect off; # Disable proxy auto-redirect handling
proxy_set_header User-Agent "$http_user_agent [ip:$remote_addr]";
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host; # Ensure correct Host header
proxy_connect_timeout 8;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_max_temp_file_size 0;
proxy_pass $stream_url$is_args$args;
rewrite / /index.html?sid=1 break;
}
i put under the proxy_pass this "rewrite / /index.html?sid=1 break;" it works correctly but its not true because shoutcast redirect automaticaly on /index.html?sid=1 and if i put on browser /index.html?sid=2, sid=3 and etc dont work because browser only reads /index.html?sid=1. can anyone help me for this ? Thanks
Upvotes: 0
Views: 53