HLS proxying multiple sources


I need a way to provide the ‘proxy_pass’ argument from external script
for hls streaming. One way will be to use exec_pull with rtmp module,
but this means to convert hls to rtmp, and run ffmpeg - pretty
cumbersome. If there is a way to do something like ** proxy_pass
my_script original_request ** (my_script is in backticks), it will be

Situation: I need to choose dynamically the server where I pull the hls
video stream from. Some of the upstream servers (usually 2-4 in total)
may be down or slow at the moment where the request comes to the local
nginx, so I need to dynamically choose the ‘preferred’ one. On top, I
have different login credentials for those, and a limit of logins per

Almost sure nginx will have some way of doing it - it does anything
imaginable - and few things beyond.

Any suggestion appreciated,
Thanks, George.