laoxong 大佬有话说 :
【教程】Nginx反代 缓存更新
之前MJJ的https://www.hostloc.com/thread-643832-1-1.html帖子有介绍,但是美中不足的是没有缓存的更新
在楼主提醒我之前写的不对时又重新研究了下,研究出了正确方法
配置文件:自己改一下
proxy_cache_path /usr/local/nginx/caches/moec.top levels=1:2 keys_zone=laoxong:50m inactive=30m max_size=50m;
server {
listen 80;
listen 443 ssl http2;
ssl_certificate /usr/local/nginx/conf/ssl/moec.crt;
ssl_certificate_key /usr/local/nginx/conf/ssl/moec.key;
ssl_session_timeout 1d;
ssl_session_cache builtin:1000 shared:SSL:10m;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers "TLS-CHACHA20-POLY1305-SHA256:TLS-AES-256-GCM-SHA384:TLS-AES-128-GCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+ECDSA+AES128:EECDH+aRSA+AES128:RSA+AES128:EECDH+ECDSA+AES256:EECDH+aRSA+AES256:RSA+AES256:EECDH+ECDSA+3DES:EECDH+aRSA+3DES:RSA+3DES:!MD5";
ssl_prefer_server_ciphers on;
ssl_stapling on;
ssl_stapling_verify on;
server_name 你的域名;
access_log /usr/local/nginx/caches/moec.top_nginx.log combined;
charset utf-8,gbk;
location / {
proxy_set_header Accept-Encoding "";
proxy_pass https://你的网站;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache laoxong;
proxy_cache_key $uri$is_args$args;
proxy_cache_valid 200 304 30m;
proxy_cache_valid 301 24h;
proxy_cache_valid 500 502 503 504 0s;
proxy_cache_valid any 1s;
proxy_cache_min_uses 1;
expires 12h;
}
location ~ /purge(/.*) {
allow all;
allow 127.0.0.1;
# deny all;
proxy_cache_purge laoxong $1$is_args$args;
}
}
完整请看 https://www.moec.top/archives/403
mryin 大佬有话说 :
学习了,写的很认真