In this instructional exercise, you will figure out how to hinder terrible bots, referrer spam, and forestall DDOS on your Nginx web server. To achieve this, we will utilize the open-source project called Nginx Ultimate Bad Bot and Referrer Blocker.
Before the finish of this instructional exercise, your Nginx server will hinder undesirable client specialist, spam referrer, adware, malware, ransomware, and clickjackers.
1. Download Nginx Bad Bot Blocker
To download the Ultimate Bad Bot Blocker, execute the following commands on your system.
2. Check Proper Placement of Includes
Sometimes, especially if you have an Let’s Encrypt SSL certificate installed, the setup script from above will incorrectly place the includes in your Nginx config file. Make that the “Nginx Bad Bot Blocker Includes” come before the first location block in your config files at
3. How to Automatically Update Nginx Bad Bot Blocker
Execute the
command and add the following statement to automatically update the Nginx Bad Bot Blocker everyday at 10 PM server time. You can optionally add the -e flag and provide an email address for notifications.
4. Configure Nginx Bad Bot Blocker
The default rules for Nginx Bad Bot Blocker at located at
- bad-referrer-words.conf
- blacklist-ips.conf
- blacklist-user-agents.conf
- blockbot.conf
- custom-bad-referreres.conf
- ddos.conf
- whitelist-domains.conf
- whitelist-ips.conf
5. Test it Out
From another IP address, you can execute on of the following curl commands to see if the blocker is working. If you get an empty reply from the server, it is working as expected.
As a temporary test, you can also blacklist yourself by adding your IP address to
Here is a full tutorial that will show you how to install and configure the Nginx Bad Bot Blocker in more detail.