Lua Variable access bug?

Sirsiwal, Umesh usirsiwal at verivue.com
Wed May 16 02:16:14 UTC 2012


Hello,
We are seeing the following problem with nginx variable access from Lua.

I have the following configuration:

            set $vv $http_host;
            set_by_lua $i ' return ngx.log(ngx.ERR, ngx.var.http_host)';

If I comment out the first line and send SIGHUP to master process the logged variable becomes empty.

            #set $vv $http_host;
            set_by_lua $i ' return ngx.log(ngx.ERR, ngx.var.http_host)';

Note that if we start nginx with set $vv $http_host; commented there is no issue. The issue only exists if we start off accessing the variable from the configuration file and than remove the variable access.

I think issue exists because of the way ngx_http_variables_init_vars is written. It changes the flags in the static ngx_http_core_variables variable. During the first configuration read cycle where $http_host is indexed, the flag changes to indexed. During the second configuration read cycle where the the $http_host variable should not be indexed, the flags still remain INDEXED. That confuses ngx_http_get_variable later. 

Thanks for any help.

-Umesh


More information about the nginx-devel mailing list