Hello!
On Fri, Mar 7, 2014 at 2:18 PM, simpson wrote:
> I'm trying to check if an nginx variable is set in lua. I'm doing
>
> if ngx.var.myvar ~= "" then
You should take into account nil values here too, that is, use the
following line instead:
if ngx.var.myvar and ngx.var.myvar ~= "" then
> where "myvar" isn't set in the nginx.conf. I'm getting
>
> 2014/03/07 14:09:50 [warn] 2127#0: *8 using uninitialized "myvar" variable,
This warning is generated by the standard ngx_rewrite module, not ngx_lua.
And this harmless warning can be disabled by adding the following line
to your nginx.conf:
uninitialized_variable_warn off;
See also
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#uninitialized_variable_warn
Best regards,
-agentzh