Welcome! Log In Create A New Profile

Advanced

Need help setting up cache for failover

December 03, 2014 08:25PM
I'm trying to configure my sites to failover to fastcgi_cache when backends are unavailable -- but at the same time I want to return nginx errors (hiding backend errors)

Here's a simplified version of my current config:

fastcgi_cache_path /dev/shm/nginx_fastcgi_cache levels=1:2 inactive=3d keys_zone=mycache:100m max_size=5000m;
fastcgi_cache_use_stale error http_500 http_503 timeout updating;
fastcgi_cache_valid 200 5m;
fastcgi_cache_valid 404 1m;
proxy_intercept_errors on;
server {
server_name domain.com
root /var/www/domain.com;
location / {
try_files $uri @hhvm_backends;
}
location @hhvm_backends {
fastcgi_pass backend-nodes; # upstream hhvm backends
fastcgi_cache mycache;
...
}
error_page 404 @404;
error_page 500 @500;
location @404 { echo "404: file not found!"; }
location @500 { return 500; } # default nginx error page
}


Right now, if the server is down and location is stale in cache, I get the default nginx 500 error page.
According to debug log, the problem with this one is that error_page handling takes over before fastcgi_cache_use_stale has a chance to do its thing.

Is there an easy way to fix this?

Thanks
Subject Author Posted

Need help setting up cache for failover

Fry-kun December 03, 2014 08:25PM

Re: Need help setting up cache for failover

B.R. December 04, 2014 03:44AM

Re: Need help setting up cache for failover

Fry-kun December 04, 2014 12:09PM

Re: Need help setting up cache for failover

B.R. December 04, 2014 02:28PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 68
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready