Using memcache to set variables

Johan Bergström johan at bergstroem.nu
Fri Aug 14 17:19:39 MSD 2009


Hey,

On Aug 14, 2009, at 11:34 , Avleen Vig wrote:

> On Aug 12, 2009, at 6:08, Johan Bergström <johan at bergstroem.nu> wrote:
>
>> We're doing something similar - through a FastCGI-app written in C  
>> - which looks up a host as key in memcached (cookie would work just  
>> as fine) and returns a backend (we have lots of different nginx  
>> backends) that the frontends proxies to. The key here is to use X- 
>> Accel-Redirect. So, in short: Yes, it's possible and delivers ~2k r/ 
>> s per frontend for us. A FastCGI/whatever app written in php/python  
>> would probably work just as well, port to C when performance is  
>> needed.
>
> Hi Johan!
>
> Thus is exactly what I'm hoping to do!
> How do you use x-accel-redirect to get the name of a backend? I've  
> never used it. Do ou have any code examples? This would be really  
> perfect.

We return for instance /backend1/$old_request from our FastCGI and  
then have a couple of location matches in order to point the request  
properly backwards:

location ~ /backend1/ {
   proxy_set_header Host $host;
   # mangle $request_uri if needed
   proxy_pass http://1.2.3.4$new_request_uri;
}

Should be rather straightforward. Good luck!

Regards,
Johan






More information about the nginx mailing list