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 ...

Get Squid Proxy Server 3.1 Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.