Welcome! Log In Create A New Profile

Advanced

proxy_cache/story and busylocks workaround

November 30, 2011 05:18AM
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
Subject Author Posted

proxy_cache/story and busylocks workaround

c0re November 30, 2011 05:18AM

Re: proxy_cache/story and busylocks workaround

c0re November 30, 2011 05:55AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 304
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready