Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to use nginx with the memcache module to check my memcache server first then if the key is not found then to fallback to my upstream servers. I see lots of examples of proxing to multiple upstream servers (e.g. round robin), but can I fallback in this manner from memcache misses?

share|improve this question
    
I am following on a similar question. Hope this helps forum.nginx.org/read.php?2,227610,227610#msg-227610 –  user124969 Jun 17 '12 at 12:16

1 Answer 1

up vote 1 down vote accepted

Sure, you can. Try something like this:

 location ~* ^.+.(css|js|jpg|png|gif|ico)$ {
        expires                 max;
        set $memcached_key      "$scheme://$host$request_uri";
        memcached_pass          127.0.0.1:11211;
        error_page              404 = @fallback;
 }

 location @fallback {
         internal;
         expires         max;
         proxy_pass      http://127.0.0.1:8080;
         include         /etc/nginx/conf.d/proxy.conf;
         break;
 }
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.