2012-11-05 65 views
2

我嘗試使用memcached的使用nginx的這個配置:nginx的memcached的

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:

的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-p ath =/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模塊= /建造/ buildd/nginx的-1.1.19/Debian的/模塊/ NGIN x-dav-ext-module

輸出中沒有ngx_http_memcached_module。

我使用的Ubuntu 12.04和nginx安裝apt-get install nginx

這是否意味着我必須安裝它才能使用memcached或其他東西?

回答

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的只能檢索事情已經存儲在內存緩存

means that are external to nginx應該最有可能是您的uwsgi應用

+0

感謝名單,它闡明瞭..但有可能通過nginx填充memcached而不在後端執行,nginx接收結果,爲什麼它不能將它保存在memcached中? – user1624522

+0

不確定爲什麼這樣,因爲沒有人打擾實施它我想 – cobaco

+1

有一個支持設置的第三方模塊,請參閱http://wiki.nginx.org/HttpMemcModule(注意第3方模塊意味着你會必須自己編譯nginx) – cobaco