Server Fault Asked by MayLeap1 on November 12, 2021
I have an upstream HLS stream that I need to proxy to the outside world. The provider doesn’t want me to have more than one connection at a time. They basically do not want to deal with infrastructure problems.
I have successfully used proxy_pass for the .ts, chunklist and playlist files and I am successfully caching the media files so that the traffic to the upstream server is on a levels as if if it were 1/2 users.
The problem is that when I tried caching the chunklist file (for just 1 second) the stream would lag/hang sometimes. If I don’t do that, then the upstream server will be hit hard (I assume)?
There must be something simple I am missing.
Latency is not really important, by the way. It can have a significant delay.
My current config:
server {
listen 80;
listen [::]:80;
server_name localhost;
root /usr/share/nginx/html;
location ~ ^/(.*pla.*) {
proxy_pass https://upstream-provider.com/$1;
proxy_ignore_headers Cache-Control;
proxy_cache_valid any 5s;
proxy_hide_header Cache-Control;
add_header Cache-Control "public, max-age=5";
proxy_cache edge-cache;
}
location ~ ^/(.*chunklist.*) {
proxy_pass https://upstream-provider.com/$1;
proxy_ignore_headers Cache-Control;
proxy_cache_valid any 1s;
proxy_hide_header Cache-Control;
add_header Cache-Control "public, max-age=1";
proxy_cache edge-cache;
}
location ~ ^/(.*media.*) {
proxy_ignore_headers Cache-Control;
proxy_cache_valid any 2m;
proxy_hide_header Cache-Control;
add_header Cache-Control "public, max-age=20";
proxy_cache edge-cache;
}
Is there any way of making my nginx download the ts/m3u8 files and serve them with a delay of a few seconds so that the cache can get filled?
I was thinking of writing a small service that handles that logic and puts it in a filesystem and make nginx serve files from the filesystem. Then I’d have to also handle providing a delayed chunklist which seems like a pain.
Any advice is welcome.
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP