Open ktalebian opened 4 years ago
Please provide the version info of Openresty/Nginx, and whether any other Nginx modules are used?
@ktalebian
AFAIK ngx.var.request_uri
if the client sent a malformed HTTP request line which aborted the HTTP protocol parsing. Meanwhile, if you have a log_by_lua*
directive inside HTTP block
(or server block) directly, the Lua code specified by this directive still has a chance to run, and when you fetch $request_uri
in your Lua code, you will get nil
.
We sometimes get an unhandled exception thrown to our nginx/error.log when we try to read
ngx.var.request_uri
and manipulate it, for example:This is corresponding to
local url = ngx.var.scheme .. '://' .. ngx.var.host .. ngx.var.request_uri
.I'm not sure how
ngx.var.request_uri
can ever be nil? Under what condition does this happen?