I'm using Nginx as a reverse proxy to serve HTTP video streams over HTTPS to avoid mixed content issues. However, I'm experiencing stuttering during video playback.
Problem:
The videos start playing but frequently pause at the same exact time during playback. Every time I try to watch a video, the stuttering happens at the exact same second.This issue occurs with both MP4 and MKV files.
The stuttering does not occur when accessing the videos directly from the backend server; it only happens when accessed through the Nginx reverse proxy.The stuttering does not occur when working with m3u8 files.
Here is my reverse proxy code:
server { gzip_static off; resolver 1.1.1.1; listen 25443 ssl; server_name my.proxy; ssl_certificate /etc/letsencrypt/live/my.proxy/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/my.proxy/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location /proxy/ { rewrite ^/proxy/(.*)$ /$1 break; proxy_pass http://example/$1; proxy_set_header User-Agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0"; proxy_set_header Referer "example"; proxy_set_header Host example; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_intercept_errors on; error_page 301 302 = @handle_redirect; } location @handle_redirect { add_header X-Debug-Redirect-URL $upstream_http_location; set $new_url $upstream_http_location; if ($new_url = "") { return 500; } add_header X-Debug-New-URL $new_url; proxy_pass $new_url; proxy_set_header User-Agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0"; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header Accept-Encoding ""; }}
Do you guys know any ways I could Optimize this nginx configuration ?
Any ways to prevent stuttering in my videos ?
What I tried:
Disabled gzip compression by setting gzip_static off;.
Adjusted buffer sizes in Nginx:Tweaked proxy_buffer_size, proxy_buffers, and proxy_busy_buffers_size.
Checked network latency:Latency between the client and server is minimal.