Forum: NGINX logging forum user names/id

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
KT Walrus (Guest)
on 2008-12-11 04:01
(Received via mailing list)
I'm hosting a forum.  I'd like to log the forum user name/id into
nginx access_log.

What is the best way to do this?

Should I have forum php code set a header with this user name/id and
somehow get this into an nginx variable I can use in the log_format
statement?

Or, some other "better" approach?

Also, is there some way to print out all nginx conf variables that are
visible (like phpinfo() does for php)?  I'm having a hard time with
the English wiki documentation as names of variables seem to be in
multiple places (some of which I can't find).

Kevin
mike (Guest)
on 2008-12-11 05:59
(Received via mailing list)
i read it too quick - i don't know if nginx can log headers. but it
would require it to log a RESPONSE header, which if it does log
headers, i am not sure it logs response headers.

better approach: do it in PHP. it will be much more portable and give
you ultimate control.
mike (Guest)
on 2008-12-11 05:59
(Received via mailing list)
i don't believe you can, unless nginx can log cookie values (i don't
recall if it can) and the username/ids are stored plaintext (which any
decent forum package shouldn't) in a cookie you can access
Igor S. (Guest)
on 2008-12-11 09:23
(Received via mailing list)
On Wed, Dec 10, 2008 at 07:46:24PM -0800, mike wrote:

> i read it too quick - i don't know if nginx can log headers. but it
> would require it to log a RESPONSE header, which if it does log
> headers, i am not sure it logs response headers.

An upstream HEADER can be logged as "$upstream_http_HEADER_NAME".

> better approach: do it in PHP. it will be much more portable and give
> you ultimate control.

Agree.
Igor S. (Guest)
on 2008-12-11 09:24
(Received via mailing list)
On Wed, Dec 10, 2008 at 07:45:15PM -0800, mike wrote:

> i don't believe you can, unless nginx can log cookie values (i don't
> recall if it can) and the username/ids are stored plaintext (which any
> decent forum package shouldn't) in a cookie you can access

Since 0.7.24, you may use $cookie_NAME.
This topic is locked and can not be replied to.