nginx memcached

时间:2012-11-05 13:04:58

标签: nginx memcached

我尝试在这个配置中使用带有memcached的nginx:

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;
    }

}

但所有请求都发送到uwsgi而没有使用memcache:

  

nginx -V

     

nginx -V nginx版本:nginx / 1.1.19 TLS SNI支持启用配置   参数: - 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模块= /建造/ buildd / nginx的-1.1.19 / Debian的/模块/ nginx的上游公平   --add模块= /建造/ buildd / nginx的-1.1.19 / Debian的/模块/ nginx的-DAV-EXT-模块

输出中没有ngx_http_memcached_module。

我使用安装了apt-get install nginx的Ubuntu 12.04和nginx。

这是否意味着我必须安装它以使用memcached或其他东西?

1 个答案:

答案 0 :(得分:3)

来自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. 

换句话说,nginx只能检索已经存储在memcache中的东西

means that are external to nginx很可能是您的uwsgi应用