Mobile app version of vmapp.org
Login or Join
Goswami781

: How can I block a user agent from all sites on my server? For the last few days, I've been suffering from what appears to be a (presumably inadvertent) DDOS attack. I've been getting so many

@Goswami781

Posted in: #Apache #HttpdConf

For the last few days, I've been suffering from what appears to be a (presumably inadvertent) DDOS attack. I've been getting so many requests from an agent identifying as "Mozilla/4.0 (compatible; ICS)" that apache eats through all the available memory.

Consequently, I'd like to block all requests accompanied by this user agent, so I tried doing this in httpd.conf:

SetEnvIfNoCase User-Agent "Mozilla/4.0 (compatible; ICS)" bad_user
Deny from env=bad_user


But when I restart apache it complains about using deny here. Without having to wrap it in a location or directory block, which would mean I'd have to add a new block for each site, is there any way I can deny access to the whole server?



UPDATE: The error I get



Restarting web server apache2
Syntax error on line 4 of /etc/apache2/httpd.conf: deny not allowed
here
[fail]

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Goswami781

2 Comments

Sorted by latest first Latest Oldest Best

 

@Nickens628

You can use the Directory directive with / as the path to apply to all folders for all sites.

example:

<Directory />
SetEnvIfNoCase User-Agent "Mozilla/4.0 (compatible; ICS)" bad_user
Deny from env=bad_user
</Directory>


You might already have a Deny from All at this level for security reasons. So, migrate it up through your directory tree until you reach a level that includes all of your sites.

10% popularity Vote Up Vote Down


 

@Dunderdale272

Generally, I think its bad practice to deny access based on the user agent, as it could really be spoofed to anything. You also could potentially block legitimate users access.

That being said, based on the apache docs, it appears you are using the correct syntax (http://httpd.apache.org/docs/2.2/howto/access.html)

What exactly is apache complaining about with the deny statement?

Before your deny statement try adding:

Order allow,deny
Allow from all

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme