add variable support to proxy_cache_valid directive

Michael_Fillios nginx-forum at forum.nginx.org
Sun Aug 6 07:04:35 UTC 2017


Hello everyone

I want to use variables in proxy_cache_valid directive like the syntax
below
« set $var10 "10m";
     proxy_cache_valid 200 $var10; »

but I get the error « invalid time value »
so I tried to tweak a little in the ngx_http_file_cache.c file and I added
the following lines:

«    ngx_http_complex_value_t            cv;
    ngx_http_compile_complex_value_t    ccv;

    ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));

    ccv.cf = cf;
    ccv.value = &value[n];
    ccv.complex_value = &cv;

    if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
            return NGX_CONF_ERROR;
    } »

the block after my code is 

«  valid = ngx_parse_time(&value[n], 1);
    if (valid == (time_t) NGX_ERROR) {
        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                           "invalid time value \"%V\"", &value[n]);
        return NGX_CONF_ERROR;
    }
»


also the output of Nginx -V is  

« 
—with-cc-opt=-O2 —add-module=../ngx_devel_kit-0.3.0
—add-module=../echo-nginx-module-0.60 —add-module=../xss-nginx-module-0.05
—add-module=../ngx_coolkit-0.2rc3 —add-module=../set-misc-nginx-module-0.31
—add-module=../form-input-nginx-module-0.12
—add-module=../encrypted-session-nginx-module-0.06
—add-module=../srcache-nginx-module-0.31 —add-module=../ngx_lua-0.10.8
—add-module=../ngx_lua_upstream-0.06
—add-module=../headers-more-nginx-module-0.32
—add-module=../array-var-nginx-module-0.05
—add-module=../memc-nginx-module-0.18
—add-module=../redis2-nginx-module-0.14
—add-module=../rds-json-nginx-module-0.14
—add-module=../rds-csv-nginx-module-0.07
—with-ld-opt=-Wl,-rpath,/usr/local/openresty/luajit/lib
—sbin-path=/usr/sbin/nginx —conf-path=etc/nginx.conf
—pid-path=file/nginx.pid —error-log-path=log/error.log
—http-log-path=log/access.log —with-http_gunzip_module
—with-http_gzip_static_module —with-http_ssl_module —with-http_geoip_module
—with-http_stub_status_module —with-file-aio —with-threads
—with-http_v2_module —with-http_slice_module —with-http_secure_link_module
—with-pcre-jit —with-openssl=/root/temp/proxy/source/openssl-1.0.2j
—with-pcre=/root/temp/proxy/source/pcre-8.39
—add-module=/root/temp/proxy/source/ngx_pagespeed-1.11.33.4-stable
—add-module=/root/temp/proxy/source/ngx_cache_purge-2.4.1
—add-module=/root/temp/proxy/source/testcookie-nginx-module
—add-module=/root/temp/proxy/source/nginx-rtmp-module
»

I'm a newbie in modifying and developing Nginx So I was wondering if anybody
could help me.

With respect.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,275874,275874#msg-275874



More information about the nginx mailing list