Forum: NGINX Logging a variable set by nginx's Lua module

2974d09ac2541e892966b762aad84943?d=identicon&s=25 danslimmon (Guest)
on 2013-07-16 17:27
(Received via mailing list)
I am trying to use the Lua module in nginx to set a variable ("foo")
based
on JSON in the body of a request. Then I want to log the value of that
variable to the access log.

Like so: https://gist.github.com/danslimmon/17f5bf4736566737cc65

However, nginx won't start with this configuration. It complains thusly:
https://gist.github.com/danslimmon/f5f789d8af8bbb06b224

Here is my "nginx -V" output:
https://gist.github.com/danslimmon/9ed99c63aa6c04b...

Thoughts? Thanks in advance.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,240917,240917#msg-240917
B7462bed943f6129ce57e557241421af?d=identicon&s=25 Marcin Deranek (Guest)
on 2013-07-16 18:02
(Received via mailing list)
On Tue, 16 Jul 2013 11:26:29 -0400
"danslimmon" <nginx-forum@nginx.us> wrote:

> However, nginx won't start with this configuration. It complains
> thusly: https://gist.github.com/danslimmon/f5f789d8af8bbb06b224

http://wiki.nginx.org/HttpLuaModule#ngx.var.VARIABLE

"Note that only already defined nginx variables can be written to."
Look at example how to do that.

Marcin
2974d09ac2541e892966b762aad84943?d=identicon&s=25 danslimmon (Guest)
on 2013-07-16 18:22
(Received via mailing list)
Thanks for the reply.

My first thought was to put a "set foo '-'" in the config, but when I
use
this pared-down example that emulates the documentation except to
replace
"content_by_lua" with "rewrite_by_lua":

https://gist.github.com/danslimmon/1ba367780f0efdd2afc5

I get "-" in the logs instead of "bar". Is it the "content"/"rewrite"
difference?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,240917,240920#msg-240920
B7462bed943f6129ce57e557241421af?d=identicon&s=25 Marcin Deranek (Guest)
on 2013-07-16 18:45
(Received via mailing list)
On Tue, 16 Jul 2013 12:22:19 -0400
"danslimmon" <nginx-forum@nginx.us> wrote:

> Thanks for the reply.
>
> My first thought was to put a "set foo '-'" in the config, but when I
> use this pared-down example that emulates the documentation except to
> replace "content_by_lua" with "rewrite_by_lua":
>
> https://gist.github.com/danslimmon/1ba367780f0efdd2afc5
>
> I get "-" in the logs instead of "bar". Is it the "content"/"rewrite"
> difference?

Shouldn't be and works for me (nginx 1.2.8) I noticed that your
example cannot work as you missed semicolon after at the end of line
with set (I get syntax error).

Marcin
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.