Nginx Plesk 502 bad gateway on proxy a radio server

Viewed 70

I have write this code to get on link https://example.com/streamradio/ip-or-host:port to proxy a radio server but i get 502 bad gateway why i get this error ? i put this code in plesk Additional nginx directives.

location ~ ^/streamradio/(.*)$ {

    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_pass http://$1;
}

But if i put this code in Additional nginx directives in plesk it works

location /streamradio/ {

    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_pass http://ip-or-host:port;
}

but i need to put the ip-or-host:port on link, example: https://example.com/streamradio/ip-or-host:port with the first code but i get 502, Can anyone be solve this problem ? Thanks

0 Answers
Related