upstream backend { server 127.0.0.1:{{http_port}}; } server { server_name {{domain}}; {% include 'roles/letsencrypt/templates/ssl_header.j2' %} {% if nginx_matomo_tracking | default(False) %} {% include 'roles/nginx-matomo-tracking/templates/matomo-tracking.conf.j2' %} {% endif %} ## # Application ## location @api { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; client_max_body_size 100k; # default is 1M proxy_connect_timeout 10m; proxy_send_timeout 10m; proxy_read_timeout 10m; send_timeout 10m; #adapt proxy_pass http://127.0.0.1:{{http_port}}; } location / { try_files /dev/null @api; } location = /api/v1/videos/upload-resumable { client_max_body_size 0; proxy_request_buffering off; try_files /dev/null @api; } location ~ ^/api/v1/videos/(upload|([^/]+/studio/edit))$ { limit_except POST HEAD { deny all; } client_max_body_size 12G; # default is 1M add_header X-File-Maximum-Size 8G always; # inform backend of the set value in bytes before mime-encoding (x * 1.4 >= client_max_body_size) try_files /dev/null @api; } location ~ ^/api/v1/(videos|video-playlists|video-channels|users/me) { client_max_body_size 6M; # default is 1M add_header X-File-Maximum-Size 4M always; # inform backend of the set value in bytes before mime-encoding (x * 1.4 >= client_max_body_size) try_files /dev/null @api; } ## # Websocket ## location @api_websocket { proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_pass http://backend; } location /socket.io { try_files /dev/null @api_websocket; } location /tracker/socket { # Peers send a message to the tracker every 15 minutes # Don't close the websocket before then proxy_read_timeout 15m; # default is 60s try_files /dev/null @api_websocket; } }