Question

i'm trying to prevent apache from loging my own visits.. I've enabled SetEnvIf.so and added these lines to my vhost :

<VirtualHost *:80>  
    ...
    SetEnvIf Remote_Addr "192\.168\.1\.1" dontlog
    SetEnvIf Remote_Addr "192\.168\.1\.5" dontlog
    SetEnvIf Remote_Addr "192\.168\.1\.10" dontlog  
</VirtualHost>

There must be something I'm doing wrong since it still logs 192.168.1.10 (.1 and .5 too) to my access.log.

Should SetEnvIf be set somewhere else instead ?

Cheers.

Was it helpful?

Solution

You should add env=!dontlog at the end of your CustomLog line.

Example (I also noticed the backslashes were not necessary):

<VirtualHost *:80> 
  ...
  SetEnvIf Remote_Addr "192.168.1.1" dontlog
  SetEnvIf Remote_Addr "192.168.1.5" dontlog
  SetEnvIf Remote_Addr "192.168.1.10" dontlog 
  ...
  CustomLog /var/log/apache2/mywebsite.access.log combined env=!dontlog
  ...
</VirtualHost>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top