Tuesday, January 12, 2016

HOWTO stop the Apache “internal dummy connection” from logging

If you see many of these entries on you Apache Website Access Log:

::1 - - [12/Jan/2016:06:25:02 +0100] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Debian) (internal dummy connection)"

You can easily prevent these entries logging by doing the following:

In our case, every VHost has its own Log File, that's we see many of these entries on the "access.log" or "other_vhosts_access.log"

To change this we can edit the following VHost file, that comes activated by default in Apache:

vim /etc/apache2/sites-available/default

and here replace the following entry:

CustomLog ${APACHE_LOG_DIR}/access.log combined

for these lines:

#Prevent logging for local requests
SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog 
SetEnvIf Remote_Addr "::1" dontlog

CustomLog ${APACHE_LOG_DIR}/access.log combined env=!dontlog

After that, we can reload apache2 and it should work right away. :)

service apache2 reload