Varnish is a caching system that has the ability to speed up your server’s ability to display webpages. Varnish sits between the Internet & your other software. This means that AWStats is unable to report on your traffic. This article will outline one option for fixing this problem with Varnish 4.
NOTE: Varnish does not handle HTTPS traffic. This means that after following these instructions AWStats will only show non-HTTPS data.
Prerequisites
This article assumes a few points that will need to be complete or in place before proceeding. They are:
- CentOS 6 or 7 server
- cPanel version 62.0 (build 17) or similar installed, and operating as normal
- Varnish 4 installed, and operating as normal
Ok, I Have All Those Installed & Operating as Normal. What now?
- Log into your server via SSH as root
- Start the Varnish logging utility that outputs in Apache log format. For CentOS 6 run
service varnishncsa start
For Centos 7 run
systemctl start varnishncsa
- Set varnishncsa to start if you server restarts
chkconfig varnishncsa on
Update LogFile variable in the AWStats configuration file with the new log location /var/log/varnish/varnishncsa.log. By default this is in the ‘awstats’ folder inside the ‘tmp’ folder of your cPanel user’s home directory. The full path for this file usually looks something like /home/userna05/tmp/awstats/awstats.primarydomain.com.conf
- Change permissions for this file to prevent cPanel from overwriting these changes. Be sure to replace ‘userna05’ with your primary cPanel user name, and ‘primarydomain.com’ with your primary domain.
chmod 444 /home/userna05/tmp/awstats/awstats.primarydomain.com.conf
- Log into cPanel for your primary cPanel user.
Access AWStats
Find your primary domain on the list of available domains, and click View next to it
Finally, click Update now at the top of the page.
Congratulations! You are now allowing AWStats to parse data from Varnish for all domains on your server.