how to reduce the Requests on apache2 server ?

Posted February 10, 2017 2.4k views
UbuntuApacheServer Optimization

how to control the same ip accessing bots
how to block that ?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

If you have IP address of bot accessing your site, you can block it using firewall or Apache config.

A firewall blocking is easier IMO, as one command will block IP to accessing your server.
On Ubuntu, you can use ufw which is very simply to configure and use.
Step 7 of Initial Server Set Up tutorial covers setting up a ufw firewall.
To block IP address, you can use following command:

  • sudo ufw deny from

Where is IP address of user/bot you want to block.
Also, you can block subnet following command:

  • sudo ufw deny from

ufw essential tutorial should give you more insight on this topic.

Second option is to block via Apache config. This could be harder, as you have to change config and restart/reload Apache every time you do so.
Apache docs should help you around this if you’re interested in it.

Be very careful when you doing above. You can sometimes block regular users or ‘good’ bot.
For example, Google uses bots to crawl and index your web site. If you block Google bot, this will affect your rank in Google Index and position on Google Search. In case of Google, you can verify are bots accessing your site their, by following steps written on their help page. Same applies for other engines, so make sure you really ban malicious bots.

by Mitchell Anicas
by Erika Heidi
UFW (uncomplicated firewall) is a firewall configuration tool that runs on top of `iptables`, included by default within Ubuntu distributions. It provides a streamlined interface for configuring common firewall use cases via the command line. This cheat sheet-style guide provides a quick reference to common UFW use cases and commands, including examples of how to allow and block services by port, network interface, and source IP address.