- add_header 'Access-Control-Allow-Origin' '*';
- add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
- add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
- add_header 'Access-Control-Max-Age' 1728000;
- add_header 'Content-Type' 'text/plain charset=UTF-8';
- add_header 'Content-Length' 0;
+ add_header Access-Control-Allow-Origin '*';
+ add_header Access-Control-Allow-Methods 'GET, OPTIONS';
+ add_header Access-Control-Allow-Headers 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
+ add_header Access-Control-Max-Age 1728000; # Preflight request can be cached 20 days
+ add_header Content-Type 'text/plain charset=UTF-8';
+ add_header Content-Length 0;
+ return 204;
+ }
+
+ add_header Access-Control-Allow-Origin '*';
+ add_header Access-Control-Allow-Methods 'GET, OPTIONS';
+ add_header Access-Control-Allow-Headers 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
+ add_header Cache-Control "public, max-age=7200"; # Cache response 2 hours
+
+ rewrite ^/static/(.*)$ /$1 break;
+
+ try_files $uri @api;
+ }
+
+ # Bypass PeerTube for performance reasons. Optional.
+ location ~ ^/static/(webseed|redundancy|streaming-playlists)/ {
+ limit_rate_after 5M;
+
+ # Clients usually have 4 simultaneous webseed connections, so the real limit is 3MB/s per client
+ set $peertube_limit_rate 800k;
+
+ # Increase rate limit in HLS mode, because we don't have multiple simultaneous connections
+ if ($request_uri ~ -fragmented.mp4$) {
+ set $peertube_limit_rate 5M;
+ }
+
+ # Use this line with nginx >= 1.17.0
+ #limit_rate $peertube_limit_rate;
+ # Or this line if your nginx < 1.17.0
+ set $limit_rate $peertube_limit_rate;
+
+ if ($request_method = 'OPTIONS') {
+ add_header Access-Control-Allow-Origin '*';
+ add_header Access-Control-Allow-Methods 'GET, OPTIONS';
+ add_header Access-Control-Allow-Headers 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
+ add_header Access-Control-Max-Age 1728000; # Preflight request can be cached 20 days
+ add_header Content-Type 'text/plain charset=UTF-8';
+ add_header Content-Length 0;