init
This commit is contained in:
134 files changed
+18678
No files matched your search
@@ -0,0 +1,118 @@
|
||||
map $uri $media_cache_control {
|
||||
default "no-store";
|
||||
~*\.m3u8$ "private, no-cache, no-store, must-revalidate";
|
||||
# Safe origin default: browsers may retain immutable generation assets, but a
|
||||
# shared CDN must not cache them until it enforces playback authorization at
|
||||
# the edge before cache lookup.
|
||||
~*\.(m4s|mp4|vtt|ass|ttf|otf)$ "private, max-age=31536000, immutable";
|
||||
}
|
||||
|
||||
upstream easy_stream_api {
|
||||
server api:3000;
|
||||
keepalive 64;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
server_name _;
|
||||
server_tokens off;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
include /etc/nginx/security-headers.conf;
|
||||
|
||||
# Cache bookkeeping is mounted beside public generations but is never media.
|
||||
location ~ (^|/)\. {
|
||||
deny all;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
# Never trust a client-supplied forwarding chain. Configure real_ip_from
|
||||
# for the selected CDN at deployment time if end-user IPs are required.
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_pass http://easy_stream_api;
|
||||
add_header Cache-Control "no-store" always;
|
||||
include /etc/nginx/security-headers.conf;
|
||||
}
|
||||
|
||||
location = /_media_auth {
|
||||
internal;
|
||||
proxy_pass_request_body off;
|
||||
proxy_set_header Content-Length "";
|
||||
proxy_set_header X-Original-URI $request_uri;
|
||||
proxy_set_header Cookie $http_cookie;
|
||||
proxy_set_header X-Media-Auth-Secret "${MEDIA_AUTH_SHARED_SECRET}";
|
||||
proxy_pass http://easy_stream_api/internal/media-auth;
|
||||
}
|
||||
|
||||
# Offline compatibility encodes are durable and live on a separate disk.
|
||||
# Keep the more-specific prefix ahead of the bounded JIT cache route.
|
||||
location /media/derived/ {
|
||||
auth_request /_media_auth;
|
||||
alias /srv/easy-stream/derived/;
|
||||
disable_symlinks on;
|
||||
types {
|
||||
application/vnd.apple.mpegurl m3u8;
|
||||
video/iso.segment m4s;
|
||||
video/mp4 mp4;
|
||||
text/vtt vtt;
|
||||
text/x-ssa ass;
|
||||
font/ttf ttf;
|
||||
font/otf otf;
|
||||
}
|
||||
add_header Cache-Control $media_cache_control always;
|
||||
include /etc/nginx/security-headers.conf;
|
||||
}
|
||||
|
||||
location /media/ {
|
||||
auth_request /_media_auth;
|
||||
alias /srv/easy-stream/cache/;
|
||||
disable_symlinks on;
|
||||
types {
|
||||
application/vnd.apple.mpegurl m3u8;
|
||||
video/iso.segment m4s;
|
||||
video/mp4 mp4;
|
||||
text/vtt vtt;
|
||||
text/x-ssa ass;
|
||||
font/ttf ttf;
|
||||
font/otf otf;
|
||||
}
|
||||
add_header Cache-Control $media_cache_control always;
|
||||
include /etc/nginx/security-headers.conf;
|
||||
}
|
||||
|
||||
# TMDB artwork stays same-origin for CSP/COEP and can be cached by the outer CDN.
|
||||
location /images/tmdb/ {
|
||||
limit_except GET HEAD { deny all; }
|
||||
rewrite ^/images/tmdb/(w500|w1280)(/.*)$ /t/p/$1$2 break;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_ssl_verify on;
|
||||
proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
|
||||
proxy_ssl_verify_depth 3;
|
||||
proxy_set_header Host image.tmdb.org;
|
||||
proxy_hide_header Set-Cookie;
|
||||
proxy_hide_header Cache-Control;
|
||||
proxy_pass https://image.tmdb.org;
|
||||
add_header Cache-Control "public, max-age=86400, stale-while-revalidate=604800" always;
|
||||
include /etc/nginx/security-headers.conf;
|
||||
}
|
||||
|
||||
location /healthz {
|
||||
access_log off;
|
||||
return 200 "ok\n";
|
||||
}
|
||||
|
||||
location /assets/ {
|
||||
try_files $uri =404;
|
||||
add_header Cache-Control "public, max-age=31536000, immutable" always;
|
||||
include /etc/nginx/security-headers.conf;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
add_header Cache-Control "no-cache";
|
||||
include /etc/nginx/security-headers.conf;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
add_header X-Content-Type-Options nosniff always;
|
||||
add_header Referrer-Policy no-referrer always;
|
||||
add_header X-Frame-Options DENY always;
|
||||
add_header Cross-Origin-Opener-Policy same-origin always;
|
||||
add_header Cross-Origin-Embedder-Policy require-corp always;
|
||||
add_header Cross-Origin-Resource-Policy same-origin always;
|
||||
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; media-src 'self' blob:; connect-src 'self'; worker-src 'self' blob:; font-src 'self' data:; frame-ancestors 'none'; base-uri 'none'; form-action 'self'" always;
|
||||
Reference in new issue
Block a user