HAProxy Block by User-Agent
From Brian Nelson Ramblings
HAProxy block by User-Agent
As with any proxy service, you will want to block bad bots. Blocking by the a keyword in the user-agent before it hits the backend servers will save on server resources.
Add the following to your haproxy configuration file
vim /etc/haproxy/haproxy.cfg
Add the following to your frontend
# Block badbots acl is-blockedagent hdr_sub(user-agent) -i -f /etc/haproxy/blacklist-agent.txt http-request deny if is-blockedagent
Save then add the blacklist-agent.txt file.
vim /etc/haproxy/blacklist-agent.txt
Block the basics
SemrushBot AhrefsBot MJ12bot ZoominfoBot DotBot MauiBot
Save and check your configuration
service haproxy check
You are looking for
Configuration file is valid
Next restart or start the server to start blocking by user-agent
service haproxy restart/start