Custom logging for Netscaler backed Apache – See Netscaler Client-IP header in log files.

By | 02/12/2012

In Netscaler backed apache web servers’ access_log files you can only see Netscaler Ip address. For statistics calculation it is hard to determine how many unique clients visited your website.

To see client’s ip adresses in log files you have to change apache config to set new log format.

First you have to set Netscaler to send Client-Ip information to web server.

Netscaler > Load Balancing > Service Groups > Advanced Tab

Select Client Ip section in settings and write a Header.

After that Netscaler sends a header information with “Client-IP” title.

Now we can change apache configuration file to define LogFormat.

Edit /etc/htttp/conf/httpd.conf file with an editor.

Find line below

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

and replace it with

LogFormat "%{Client-IP}i %l %u %t \"%r\" %>s %b \"%{Referer}i\"\"%{User-Agent}i\"" combined

Restart apache then you can see Client ip information in access_log files.