V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
xiaoz
V2EX  ›  NGINX

Nginx ngx_cache_purge 报错

  •  
  •   xiaoz ·
    helloxz · 2017-11-14 17:43:18 +08:00 · 2691 次点击
    这是一个创建于 2354 天前的主题,其中的信息可能已经有所发展或是发生改变。

    原本没有 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 就可以正常启动,还有其它什么原因么?

    1 条回复    2017-11-14 18:07:05 +08:00
    xiaoz
        1
    xiaoz  
    OP
       2017-11-14 18:07:05 +08:00
    已经解决,原因是 proxy_cache_purge cache_one $host$1$is_args$args;其中 cache_one 需要和 keys_zone 后面名称不一致导致,改成和 keys_zone 一致可以了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5257 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 09:20 · PVG 17:20 · LAX 02:20 · JFK 05:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.