NGINX Log Customization

Revision as of 11:27, 14 June 2011 by Fmarques (talk | contribs)

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: - - [14/Jun/2011:11:17:03 +0100]  "GET /zimbra/ HTTP/1.1" 200 22830
 "" "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

For more information on Nginx log_format directive please check

This has been tested in ZCS 6.0.10.

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

Jump to: navigation, search