Memcached logging and setup question

Joel Eidsath joel at
Wed Aug 10 20:00:18 UTC 2011

Hello fellow Nginx-ers,

We have our nginx server set up with a "maintenance mode" (for
upgrades) that will display an error page until the maintenance mode
is turned off.

However, I'd like memcached to bypass this and serve anything it has
cached even when the maint mode is on. So I've made the following
modification (moved the if statement), which doesn't seem to work:

# maintenance mode old setup
# if ( $maintenance )                         { return 503; }

location / {

         if ($request_method != GET) {
            proxy_pass http://backend;
        default_type "text/html";
        set $memcached_key "http://<SERVER_NAME>$uri";
        memcached_pass <SERVER_IP>:<MEMCACHE_PORT>;
        error_page 404 502 = @cache_miss;

location @cache_miss       { proxy_pass http://backend;
    # new maintenance mode if statement location
    if ( $maintenance ) { return 503; }

Now, when the maintenance flag is set, nginx returns 503 for
everything, as if it were missing the cache every time.

Any suggestions?

Also, is there a way for me to enable nginx logging of these memcached
results? For debugging I'd like to be able to see hits, misses, keys,



More information about the nginx mailing list