Files
restream-tools/scripts/nginx/restream.conf
T

104 lines
2.6 KiB
Plaintext

# Sample configuration for HLS stream cache server
# Ref: https://docs.peer5.com/guides/use-nginx-as-wowza-cache/
worker_processes auto;
events {
worker_connections 16384;
multi_accept on;
use epoll;
}
error_log /dev/stderr;
http {
# Basic settings
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
keepalive_timeout 300s;
types_hash_max_size 2048;
include ./nginx/conf/mime.types;
default_type application/octet-stream;
# Logging settings
access_log /dev/stdout;
# Set DNS resolver
resolver 1.1.1.1 8.8.8.8 valid=300s ipv6=off;
resolver_timeout 10s;
# TODO: Update cache path to your cache directory
proxy_cache_path
# cache directory (e.g. /var/cache/nginx/proxy_cache)
cache
use_temp_path=off
# the name of the cache, if you change this
# you have to update the proxy_cache directive below
keys_zone=restream_cache:10m
# maximum size of the cache, feel free to tune it
max_size=20g
inactive=10m;
upstream restream {
# TODO: Add your upstream here. For HTTP-only
# upstreams, omit the :443, and change the
# https:// to http:// in the proxy_pass directive.
server restream.dev:443;
}
# Server configuration
server {
# Example SSL config
# listen 443 ssl;
# listen [::]:443 ssl;
# server_name example.com;
# ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
# Or for non-SSL
listen 8080;
listen [::]:8080;
server_name _; # TODO: change with your domain name
proxy_redirect off;
proxy_http_version 1.1;
proxy_read_timeout 10s;
proxy_send_timeout 10s;
proxy_connect_timeout 10s;
proxy_cache restream_cache;
proxy_cache_methods GET HEAD;
proxy_cache_key $uri;
proxy_cache_valid 200 302 5m;
proxy_cache_valid 404 3s;
proxy_cache_lock on;
proxy_cache_lock_age 5s;
proxy_cache_lock_timeout 1h;
proxy_ignore_headers Cache-Control;
proxy_ignore_headers Set-Cookie;
# Optional: Add your custom headers here
add_header X-Edge-Cache-Status $upstream_cache_status;
add_header X-Edge-Region us-east;
add_header X-Edge-Server my-server;
location ~ \.(m3u8|mpd)$ {
proxy_cache_valid 200 302 1s;
proxy_pass https://restream;
}
location / {
proxy_pass https://restream;
}
}
# Optional: redirect all requests to https
# server {
# listen 80;
# listen [::]:80;
# server_name _;
# return 307 https://$server_name$request_uri;
# }
}