nginx caching reverse proxy config
This is a good-enough example configuration for a caching reverse proxy for HLS live streams.
See it in action
# Download and compile a local version of nginx
$ ./build.sh
# Run the example configuration
$ ./run.sh
Once running, check out http://localhost:8080. By The
example config proxies to restream.dev, so you should see a blank player page.
Feel free to check out the restream.conf file and tune it to your liking.
The build script doesn't litter your system with random junk. When you're done
you can just wipe the ./nginx folder.
Merging with your existing nginx
If you don't wanna bother merging the config, you can just use your existing nginx to reverse-proxy to this one.
If you want to merge it with an existing nginx config, you can copy these
directives to the http block:
resolverandresolver_timeout(if you plan on using a domain name for the upstream)proxy_cache_pathupstream
And then you can copy the server block in too. If you want to merge it with an
existing server, you can just copy all the proxy_ directives. Note that
it'll add caching to the whole server by default, so if you don't want that,
you can change proxy_cache to off, and then in the location blocks where
you do the reverse proxy, set proxy_cache back to restream_cache.
Feel free to tweak the parameters to fit your needs, but generally the values in
restream.conf should just work alright for caching live streams.