NGINX Log Customization

Revision as of 11:08, 14 June 2011 by Fmarques (talk | contribs)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

You can customize Nginx logs in order to get more detailed information. For example, in order to get session cookie information on nginx.access.log, you can do the following (make sure you have done a backup on all the files that are going to be edited):

1) As user root, please edit the file /opt/zimbra/conf/nginx/templates/nginx.conf.web.template. Add the following configuration between zmroute_timeout and ${web.http.enabled} ... :

 log_format zcookie '$remote_addr - $remote_user [$time_local]  '
 '"$request" $status $body_bytes_sent '
 '"$http_referer" "$http_user_agent" - "$http_cookie"';

2) Edit the files /opt/zimbra/conf/nginx/templates/nginx.conf.web.https.template and /opt/zimbra/conf/nginx/templates/nginx.conf.web.http.template. Just before "location /" please add:

 access_log log/nginx.access.log zcookie;

3) Restart nginx with (run as zimbra):

 $ zmproxyctl restart

You should be able to see the cookie session information on nginx.access.log. Example:

 10.1.1.1 - - [14/Jun/2011:11:17:03 +0100]  "GET /zimbra/ HTTP/1.1" 200 22830
 "http://proxy.domain.com/zimbra/" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, 
 like Gecko) Chrome/12.0.742.91 Safari/534.30" - "ZM_TEST=true; JSESSIONID=mqryynd6hbh2;
 ZM_TEST=true; ZM_AUTH_TOKEN=0_86914ef88589fb0ebe16806f3c42ed461a24a108_69643d33363a6435
 6235613766622d656131302d346536662d383835302d6638353136383031351438343b6578703d31333a313
 330383231393432323538363b747970653d363a7a696d6272613b"

For more information on Nginx log_format directive please check http://wiki.nginx.org/HttpLogModule#access_log.

--Fmarques 04:08, 14 June 2011 (PDT)

Jump to: navigation, search