proxy_cache/story and busylocks workaround

c0re nginx-forum at nginx.us
Wed Nov 30 10:18:57 UTC 2011


proxy_cache workaround:

http{
        proxy_cache_path /cache keys_zone=localcache:10m;
        limit_zone perUri $uri 10m;
}
server {
        location /remote/ {
                try_files $uri @fake @proxy-remote;
        }
        location @fake {
                root /notexists;
        }
        location @proxy-remote {
                limit_conn perUri 1;
                proxy_cache localcache;
                proxy_cache_valid any 999d;
                proxy_cache_key "remote$request_uri"; # fix to suit your
needs
                proxy_set_header Range ""; # don't pass range requests
to upstream in this section, otherwise response won't be cached
                proxy_pass upstream;
                error_page 503 = @locked-remote;
        }
        location @locked-remote {
                # take your own. e.g.:
                proxy_buffering off;
                proxy_pass upstream;
        }
        # copy paste locations if you need (feel free to share common
@fake)
}

http://pastie.org/private/meuzkrrvanhgojuoz0mvxa

In case of proxy_store just remove @fake and set right root in /remote/

This is just a PoC, so you have to change it up to your needs.
It really works and nginx really rox =]
Any questions? - Welcome

icq:3016467 skype:imperial.roaming

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,219354,219354#msg-219354



More information about the nginx mailing list