Welcome! Log In Create A New Profile

Advanced

Re: Return file when it's in cache/check if file exists in cache

September 06, 2013 04:48AM
Ok, maybe not so beautiful solution but upstream can be used with one server makred as down.

http {
upstream backend-jail {
server 0.0.0.0 down;
}

server {
listen 80;

underscores_in_headers on;

recursive_error_pages on;
error_page 597 = @jail;

location / {
if ($http_x_backend_down = "1") {
return 597;
}

proxy_pass http://lcoalhost:8080;
proxy_set_header Host $host;

proxy_cache my-cache;
proxy_cache_valid 200 302 1h;
proxy_cache_valid 404 1m;
proxy_cache_key $uri$is_args$args;
}

location @jail {
# dont need to log error about 'no live upstreams'
error_log /dev/null crit;

# backend-jail always return 502, want 404 to be returned.
error_page 502 =404 /;

proxy_pass http://backend-jail;
}
}
}
SubjectAuthorPosted

Return file when it's in cache/check if file exists in cache

ixosSeptember 03, 2013 08:52AM

Re: Return file when it's in cache/check if file exists in cache

ixosSeptember 06, 2013 04:48AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 126
Record Number of Users: 7 on March 06, 2014
Record Number of Guests: 229 on August 01, 2014
Powered by nginx    Powered by FreeBSD    PHP Powered    Powered by Percona     ipv6 ready