multihop, but with memcached
Corey Donohoe
atmos at atmos.org
Fri May 16 01:33:41 MSD 2008
On Thu, May 15, 2008 at 3:24 PM, Adam Wiggins <adam at heroku.com> wrote:
> 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;
> }
>
>
We use includes, it's not perfect but it cuts down on a lot of duplication.
--
Corey Donohoe
http://www.atmos.org/
http://www.engineyard.com/
More information about the nginx
mailing list