Hello,
I experience issues with some bad robots especially Yandex bots which are doing DOS-like requests to the server.
I tried to setup modsecurity to block the robots but the apache will give me error after restart:
I am not sure where is the issue. Any help is much appreciated!
Here's the instructions of the setup...
First, create new folders and file for the custom stuff:
Then put this code to the conf file:
Now, create an new file called badbots.txt into the same dir:
Let's put some bad bots inside:
Make the files executable:
Before restarting the server, we include our custom conf to httpd:
Put this line of code inside the file:
Finally, rewrite confs which will also restart apache:
I experience issues with some bad robots especially Yandex bots which are doing DOS-like requests to the server.
I tried to setup modsecurity to block the robots but the apache will give me error after restart:
Code:
Starting The Apache HTTP Server...
AH00526: Syntax error on line 1 of /usr/local/directadmin/custombuild/custom/modsecurity/conf/block_user_agents.conf:
ModSecurity: Found another rule with the same id
httpd.service: main process exited, code=exited, status=1/FAILURE
kill: cannot find process ""
httpd.service: control process exited, code=exited status=1
Failed to start The Apache HTTP Server.
Unit httpd.service entered failed state.
httpd.service failed.
I am not sure where is the issue. Any help is much appreciated!
Here's the instructions of the setup...
First, create new folders and file for the custom stuff:
Code:
mkdir /usr/local/directadmin/custombuild/custom/modsecurity
mkdir /usr/local/directadmin/custombuild/custom/modsecurity/conf
cd /usr/local/directadmin/custombuild/custom/modsecurity/conf
nano block_user_agents.conf
Then put this code to the conf file:
Code:
SecRule REQUEST_HEADERS:User-Agent "@pmFromFile badbots.txt" "id:350001,rev:1,severity:2,log,msg:'BAD BOT - Detected and Blocked. '"
Now, create an new file called badbots.txt into the same dir:
Code:
nano badbots.txt
Let's put some bad bots inside:
Code:
AhrefsBot
Anonymizer
Attributor
Baidu
Bandit
BatchFTP
Bigfoot
Black.Hole
Bork-edition
DataCha0s
Deepnet Explorer
desktopsmiley
DigExt
feedfinder
gamingharbor
heritrix
ia_archiver
Indy Library
Jakarta
Java
juicyaccess
larbin
linkdex
Missigua
MRSPUTNIK
Nutch
panscient
plaNETWORK
Snapbot
Sogou
TinEye
TwengaBot
Twitturly
User-Agent
Viewzi
WebCapture
XX
Yandex
YebolBot
MJ12bot
masscan
baidu
Yandex
RSSingBot
Scanbot
betaBot
DotBot
SemrushBot
mj12bot
FeedFetcher
seoscanners.net
Moreover
ltx71
inboundlinks.win
sitebot
Make the files executable:
Code:
chmod +x block_user_agents.conf
chmod +x badbots.txt
Before restarting the server, we include our custom conf to httpd:
Code:
nano /etc/httpd/conf/extra/httpd-includes.conf
Put this line of code inside the file:
Code:
Include /usr/local/directadmin/custombuild/custom/modsecurity/conf/*.conf
Finally, rewrite confs which will also restart apache:
Code:
cd /usr/local/directadmin/custombuild
./build rewrite_confs
Last edited: