How to setup Nginx as REALLY static-cache reverse proxy
austevo
nginx-forum at forum.nginx.org
Fri Jan 8 01:03:02 UTC 2016
Thanks for the responses guys.
I've tried proxy_store on one config, but now I'm just receiving time-outs
when I block the origin server. No stale cache on error at all.
Here are two separate configs I'm using. The first one is as described
earlier, with caching and stale cache errors working, although cache is
browser dependent.
proxy_cache_path /etc/nginx/cache/abc123.org levels=1:2 keys_zone=abc123:64m
inactive=10d max_size=1000m;
server {
listen 443 ssl;
server_name abc123.org;
access_log /var/log/nginx/abc123.org.access.log;
error_log /var/log/nginx/abc123.org.error.log;
include ssl.conf;
#moved from location
proxy_cache_key abc123$request_uri;
location / {
proxy_cache abc123;
#proxy_cache_key abc123$request_uri;
add_header X-Proxy-Cache $upstream_cache_status;
proxy_pass https://abc123.org;
proxy_cache_valid 200 720m;
proxy_cache_valid 301 304 302 720m;
proxy_cache_use_stale error timeout invalid_header updating http_500
http_502 http_503 http_504 http_404;
expires max;
add_header Cache-control "public";
proxy_connect_timeout 3s;
proxy_read_timeout 3s;
proxy_send_timeout 3s;
proxy_cache_revalidate on;
proxy_cache_min_uses 1;
}
}
server {
listen 80;
server_name abc123.org;
return 301 https://$server_name$request_uri;
}
Config with proxy_store
proxy_cache_path /etc/nginx/cache/zxf123.org levels=1:2 keys_zone=zxf123:64m
inactive=10d max_size=1000m;
server {
listen 443 ssl;
server_name zxf123.org;
access_log /var/log/nginx/zxf123.org.access.log;
error_log /var/log/nginx/zxf123.org.error.log;
include ssl.conf;
#moved from location
proxy_cache_key $host$request_uri;
location / {
#proxy_cache zxf123;
proxy_store on;
#proxy_cache_key $host$request_uri;
add_header X-Proxy-Cache $upstream_cache_status;
proxy_pass https://zxf123.org;
proxy_cache_valid 200 720m;
proxy_cache_valid 301 304 302 720m;
proxy_cache_use_stale error timeout invalid_header updating http_500
http_502 http_503 http_504 http_404;
expires max;
add_header Cache-control "public";
proxy_connect_timeout 3s;
proxy_read_timeout 3s;
proxy_send_timeout 3s;
proxy_cache_revalidate on;
proxy_cache_min_uses 1;
}
}
server {
listen 80;
server_name zxf123.org;
return 301 https://zxf123.org$request_uri;
}
Posted at Nginx Forum: https://forum.nginx.org/read.php?2,255256,263893#msg-263893
More information about the nginx
mailing list