multihop, but with memcached
Adam Wiggins
adam at heroku.com
Fri May 16 01:24:09 MSD 2008
In the config below, the request has three branches through which it may travel:
- Request is a GET, serve from memcached if the key exists.
- Request is a GET, memcached returns a 4040, so fallback to the app server.
- Request is a POST, PUT, or DELETE, so go straight to the app server.
My question is, how can I unify the second two branches, so as not to
duplicate all the config directives for that branch?
location / {
if ($request_method = GET) {
set $memcached_key $uri;
memcached_pass 127.0.0.1:11211;
error_page 404 502 = @myapp;
break;
}
# app config block
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://myapp_mongrels;
}
location @myapp {
# app config block (duplicate)
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://myapp_mongrels;
}
More information about the nginx
mailing list