Time for action – enabling the referer log
By default, there is no referer log. We can enable the referer log using the access_log
directive in combination with a custom log format. To generate the referer log, first of all, we need to create a log format as shown:
logformat referer %ts.%03tu %>a %{Referer}>h %ru
This configuration defines a new log format called referer
, which contains a request timestamp, IP address of the client, the referer URL, and the request URL. Now, we need to use the access_log
directive with the aforementioned constructed log format as shown:
access_log /opt/squid/var/logs/referer.log referer
Now, let's look at a few lines from the referer log file:
1284576601.898 127.0.0.1 http://en.wikipedia.org/wiki/Main_Page http://en.wikiquote.org/wiki/Main_Page 1284576607.732 127.0.0.1 http://en.wikiquote.org/wiki/Main_Page http://upload.wikimedia.org/wikiquote/en/b/bc/Wiki.png
The referer log is a bit easier to understand. The first column is the time elapsed since epoch...