在使用通过 Nginx 反向代理方式部署的 Cloudreve 内置的播放功能播放视频时,会出现严重卡顿。
具体原因是 Nginx 的代理功能默认是不开启 Rander ,导致每次播放视频时,视频文件使用200响应,而不是206响应,从而导致播放时出现卡顿。
症状可以参照:https://github.com/cloudreve/Cloudreve/issues/1833
解决方案:
以宝塔为例,在 Nginx 的代理的配置文件中使用以下配置,已经融合宝塔自动生成的配置和额外增加的 Ranger 配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
location / { proxy_pass http://127.0.0.1:5212; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade;
proxy_http_version 1.1; proxy_set_header Range $http_range; proxy_set_header If-Range $http_if_range; proxy_set_header Connection "keep-alive";
add_header X-Cache $upstream_cache_status;
set $static_fileJycnv0oM 0; if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" ) { set $static_fileJycnv0oM 1; expires 1m; } if ( $static_fileJycnv0oM = 0 ) { add_header Cache-Control no-cache; } }
|
注意:不要开启缓存,会导致新建和删除文件不显示。
参考:https://www.cnblogs.com/zhangyong/p/15295806.html