1
我設置了一個Nginx反向代理服務器,服務於另一臺服務器上託管的mp4文件。除緩存外,現在一切正常。雖然我的proxy_cache_valid
設置爲1天(proxy_cache_valid any 1d
),但緩存將在短時間後自動刪除(我認爲是5-10分鐘)。我的文件大小範圍從200 - 1500MB(平均700MB)。Nginx是否會自動刪除設置爲有效的緩存?
我無法弄清楚配置有什麼問題。任何事情都可能有幫助
下面是配置
worker_processes auto;
worker_rlimit_nofile 100000;
events {
worker_connections 5000;
multi_accept on;
use epoll;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 10;
keepalive_requests 1024;
client_body_timeout 12;
client_header_timeout 12;
send_timeout 10;
proxy_cache_path /tmp/mycache keys_zone=mycache:10m use_temp_path=off;
limit_conn_zone $binary_remote_addr zone=addr:10m;
server {
listen 80;
server_name localhost;
access_log off;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
open_file_cache max=10000 inactive=30s;
open_file_cache_valid 60s;
open_file_cache_min_uses 5;
open_file_cache_errors on;
client_body_buffer_size 16K;
client_header_buffer_size 1k;
client_max_body_size 8m;
large_client_header_buffers 2 1k;
location/{
proxy_cache mycache;
proxy_max_temp_file_size 1924m;
slice 100m;
proxy_cache_key $host$uri$slice_range;
proxy_set_header Range $slice_range;
proxy_http_version 1.1;
proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;
proxy_cache_valid any 1d;
limit_conn addr 5;
proxy_pass http://domain2.com/;
secure_link $arg_md5,$arg_expires;
secure_link_md5 "secret$secure_link_expires$uri";
if ($secure_link = "") { return 403; }
if ($secure_link = "0") { return 410; }
}
}
}
安裝'nginx-debug'版本並在您的位置塊中添加'error_log /tmp/nginx.error.log調試;'你會看到更多詳細信息記錄什麼 –
謝謝。原來'proxy_cache_valid'不是決定緩存到期時間的指令。在'proxy_cache_path'中我添加了'inactive = 3h',現在一切正常。 –
非常感謝您的分享,請將其添加爲答案並接受它:-) –