Trying to find a better htaccess banning method, to avoid flooding my logs

Discussion in 'Apache' started by sabin, Jan 5, 2012.

  1. #1
    Hello,

    I'm banning a lot of IPs as well as countries from one of my websites, using htaccess protection, and redirecting them instead to an image with an explanation.

    The problem is that it is FLOODING my domain's error_log, making it a pain to browse. For 1 "meaningful" entry, I have around 100 "client denied by server configuration" reports.

    Please, would you have an alternative banning method to suggest, one that would
    - stop recording each denied access in the logs
    - still show something configurable to the denied persons, ideally an image whose URL I can chose, or else a string of text that I can write ?

    Thank you VERY much if you can help, I'll be grateful ! :)

    My htaccess banning method, currently, is, taking a few example lines :
    ErrorDocument 403 http://inter.net/folder/an_image.jpg
    <Limit GET HEAD POST>
    order allow,deny
    deny from .cn
    (...)
    deny from 85.97.233.111
    (...)
    allow from all
    </LIMIT>
    Code (markup):
    If server info is required, the server is running apache2, php5 with suhosin, it's a debian squeeze with webmin + virtualmin, but the banning has to be done with the website's htaccess and not with iptables (so that somebody else with limited ftp access to just that website can still edit ban rules without being granted my root access required to update iptables rules).

    Thank you very much if you can help :)
     
    Last edited: Jan 5, 2012
    sabin, Jan 5, 2012 IP
  2. AnthonyG

    AnthonyG Well-Known Member

    Messages:
    114
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    135
    #2
    You might be able to achive this with log_config_module for apache and set up the rules you need.

    http://httpd.apache.org/docs/current/mod/mod_log_config.html


    Here is another poss.

    You can exclude some requests, by setting environment variables using SetEnvIf and adding env=!variable clause to the CustomLog directive in your apache configuration.

    For example, if you have your images located in /images directory, you can exclude all requests to that directory from main log and if you want, log them in a separate log.


    SetEnvIf Request_URI "^/images/" images
    CustomLog /logs/example.com/access.log combined env=!images
    CustomLog /logs/example.com/images_access.log combined env=images
     
    AnthonyG, Jan 5, 2012 IP
  3. sabin

    sabin Well-Known Member

    Messages:
    114
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    130
    #3
    Hmmm... There's feed for thought, here...

    Thank you very much, Anthony ! :)
     
    sabin, Jan 9, 2012 IP