Nginx ngx_cache_purge 报错

2017-11-14 17:43:18 +08:00
 xiaoz

原本没有 ngx_cache_purge 模板,于是在测试服务器将 ngx_cache_purge 模块编译好,并将 nginx 拷贝到新服务器,nginx -V查看现有模块如下:

nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) 
built with OpenSSL 1.1.0e  16 Feb 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-pcre=/usr/local/pcre-8.39 --with-pcre-jit --with-zlib=/usr/local/zlib-1.2.11 --with-openssl=/usr/local/openssl-1.1.0e --add-module=/usr/local/ngx_http_substitutions_filter_module --add-module=/usr/local/ngx_cache_purge

按理已经编译好了ngx_cache_purge,加入下面的配置:

location ~ /purge(/.*) {
allow all;
proxy_cache_purge cache_one $host$1$is_args$args;
#proxy_cache_purge cache_one $host;
error_page 405 =200 /purge$1;
}

就报错了,报错信息如下:

nginx: [emerg] "proxy_cache" zone "cache_one" is unknown in /usr/local/nginx/conf/nginx.conf:152

检查了 keys_zone 参数是已经配置了的,将上述配置去掉后 nginx 就可以正常启动,还有其它什么原因么?

2693 次点击
所在节点    NGINX
1 条回复
xiaoz
2017-11-14 18:07:05 +08:00
已经解决,原因是 proxy_cache_purge cache_one $host$1$is_args$args;其中 cache_one 需要和 keys_zone 后面名称不一致导致,改成和 keys_zone 一致可以了。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/406362

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX