2
votes

I try to use nginx with memcached with this configuration:

server {

    ...

    location / {
    default_type            text/html;
    set $memcached_key      $uri;
        memcached_pass 127.0.0.1:11211;
        error_page     404 = @fallback;
    }

    location @fallback {
        include uwsgi_params;
        uwsgi_pass unix:///var/tmp/site.sock;
    }

}

But all requests go to uwsgi with no memcache use:

nginx -V

nginx -V nginx version: nginx/1.1.19 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-auth-pam --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-echo --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-upstream-fair --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-dav-ext-module

There is no ngx_http_memcached_module in output.

I use Ubuntu 12.04 and nginx installed with apt-get install nginx.

Does that mean I must install it to use memcached or something else?

1
Hi, how did you install that module?Edik Mkoyan

1 Answers

3
votes

from http://nginx.org/en/docs/http/ngx_http_memcached_module.html#memcached_pass

The ngx_http_memcached_module module allows to obtain responses from a memcached 
server. The key is set in the $memcached_key variable. A response should be put 
in memcached in advance via means that are external to nginx. 

in other words, nginx can only retrieve things already stored in memcache

the means that are external to nginx should most likely be your uwsgi app