.TH "nbbb.config" 1 "23rd March 2017" "version: 2.2017.05" "INSTRUCTIONS" .SH CONFIGURATION OF THE NGINX BAD BOT BLOCKER: PLEASE READ CONFIGURATION INSTRUCTIONS BELOW THOROUGHLY Created by: \[la]https://github.com/mitchellkrogza\[ra] Copyright Mitchell Krog \[la]mitchellkrog@gmail.com\[ra] Version 2.2017.05 .PP \fBIf you miss one step you will get an nginx EMERG error. This is normally a result of not downloading either blockbots.conf, ddos.conf, whitelist\-ips.conf, whitelist\-domains.conf or blacklist\-user\-agents.conf into your /etc/nginx/bots.d folder. If any of the include files are missing Nginx will EMERG and will not reload.\fP .SH AUTO INSTALLATION INSTRUCTIONS .PP To Make Sure you copy all the correct files you can now use a simple bash setup script for copying the files into the correct nginx folders for you: See: \[la]https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/installnginxblocker.sh\[ra] .PP \fBPlease Note:\fP the bash installer script does not carry out STEP 7 of the manual configuration instructions for you. YOU MUST edit any vhosts files yourself and manually add the entries in STEP 7 or the blocker will not actually be protecting any sites. .SH MANUAL INSTALLATION INSTRUCTIONS .SH STEP 1: .PP \fBCOPY THE GLOBALBLACKLIST.CONF FILE FROM THE REPO\fP .PP Copy the contents of \fB/conf.d/globalblacklist.conf\fP into your /etc/nginx/conf.d folder. .PP \fB\fCcd /etc/nginx/conf.d\fR .PP \fB\fCsudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx\-ultimate\-bad\-bot\-blocker/master/conf.d/globalblacklist.conf \-O globalblacklist.conf\fR .SH STEP 2: .PP \fBCOPY THE INCLUDE FILES FROM THE REPO\fP .RS .IP \(bu 2 From your command line in Linux type .RE .PP \fB\fCsudo mkdir /etc/nginx/bots.d\fR .PP \fB\fCcd /etc/nginx/bots.d\fR .RS .IP \(bu 2 copy the blockbots.conf file into that folder .RE .PP \fB\fCsudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx\-ultimate\-bad\-bot\-blocker/master/bots.d/blockbots.conf \-O blockbots.conf\fR .RS .IP \(bu 2 copy the ddos.conf file into the same folder .RE .PP \fB\fCsudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx\-ultimate\-bad\-bot\-blocker/master/bots.d/ddos.conf \-O ddos.conf\fR .SH STEP 3: .PP \fBWHITELIST ALL YOUR OWN DOMAIN NAMES AND IP ADDRESSES\fP .PP Whitelist all your own domain names and IP addresses. \fBPlease note important changes\fP, this is now done using include files so that you do not have to keep reinserting your whitelisted domains and IP addresses every time you update. .PP \fB\fCcd /etc/nginx/bots.d\fR .RS .IP \(bu 2 copy the whitelist\-ips.conf file into that folder .RE .PP \fB\fCsudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx\-ultimate\-bad\-bot\-blocker/master/bots.d/whitelist\-ips.conf \-O whitelist\-ips.conf\fR .RS .IP \(bu 2 copy the whitelist\-domains.conf file into the same folder .RE .PP \fB\fCsudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx\-ultimate\-bad\-bot\-blocker/master/bots.d/whitelist\-domains.conf \-O whitelist\-domains.conf\fR .PP Use nano, vim or any other text editor to edit both whitelist\-ips.conf and whitelist\-domains.conf to include all your own domain names and IP addresses that you want to specifically whitelist from the blocker script. .PP When pulling any future updates now you can simply pull the latest globalblacklist.conf file and it will automatically include your whitelisted domains and IP addresses. .SH STEP 4: .PP \fBBLACKLIST USING YOUR OWN CUSTOM USER\-AGENT BLACKLIST\fP .PP Copy the custom User\-Agents blacklist file into your /etc/nginx/bots.d folder .PP \fB\fCcd /etc/nginx/bots.d\fR .RS .IP \(bu 2 copy the blacklist\-user\-agents.conf file into the same folder .RE .PP \fB\fCsudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx\-ultimate\-bad\-bot\-blocker/master/bots.d/blacklist\-user\-agents.conf \-O blacklist\-user\-agents.conf\fR .PP Use nano, vim or any other text editor to edit (if needed) blacklist\-user\-agents.conf to include your own custom list of bad agents that are not included in the blocker like "omgilibot" which some people choose to block. .SH STEP 5: .PP \fBINCLUDE IMPORTANT SETTINGS IN NGINX.CONF\fP \fBAlso see SAMPLE\-nginx.conf file in the root of this repository\fP .PP \fB\fCcd /etc/nginx/conf.d\fR .RS .IP \(bu 2 copy the botblocker\-nginx\-settings.conf file directly from the repo .RE .PP \fB\fCsudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx\-ultimate\-bad\-bot\-blocker/master/conf.d/botblocker\-nginx\-settings.conf \-O botblocker\-nginx\-settings.conf\fR .PP \fBWhat is included in this settings file above for nginx?\fP The important settings file above adds the rate limiting functions and hash_bucket settings for nginx for you. Below is what the file contains, you cn add these manually to your nginx.conf file if you so please but the include file above will do it for you ad nginx loads any .conf file in /etc/conf.d (See STEP 6) .PP .RS server\fInames\fPhash\fIbucket\fPsize 64; .PP server\fInames\fPhash\fImax\fPsize 4096; .PP limit\fIreq\fPzone $binary\fIremote\fPaddr zone=flood:50m rate=90r/s; .PP limit\fIconn\fPzone $binary\fIremote\fPaddr zone=addr:50m; .RE .PP \fBPLEASE NOTE:\fP The above rate limiting rules are for the DDOS filter, it may seem like high values to you but for wordpress sites with plugins and lots of images, it's not. This will not limit any real visitor to your Wordpress sites but it will immediately rate limit any aggressive bot. Remember that other bots and user agents are rate limited using a different rate limiting rule at the bottom of the globalblacklist.conf file. .PP The server\fInames\fPhash settings allows Nginx Server to load this very large list of domain names and IP addresses into memory. You can tweak these settings to your own requirements. .SH STEP 6: \fBVERY IMPORTANT\fP .PP \fBMAKE SURE\fP that your nginx.conf file contains the following include directive. If it's commented out make sure to uncomment it or none of this will work. .RS .IP \(bu 2 \fB\fCinclude /etc/nginx/conf.d/*\fR .RE .SH STEP 7: \fBVERY IMPORTANT\fP .PP \fBADD INCLUDE FILES INTO A VHOST\fP .PP Open a site config file for Nginx (just one for now) and add the following lines. .PP \fBVERY IMPORTANT NOTE:\fP .PP These includes MUST be added within a \fBserver {}\fP block of a vhost otherwise you will get EMERG errors from Nginx. .RS .IP \(bu 2 \fB\fCinclude /etc/nginx/bots.d/blockbots.conf;\fR .IP \(bu 2 \fB\fCinclude /etc/nginx/bots.d/ddos.conf;\fR .RE .SH STEP 8: .PP \fBTESTING YOUR NGINX CONFIGURATION\fP .PP \fB\fCsudo nginx \-t\fR .PP If you get no errors then you followed my instructions so now you can make the blocker go live with a simple. .PP \fB\fCsudo service nginx reload\fR .PP The blocker is now active and working so now you can run some simple tests from another linux machine to make sure it's working. .SH STEP 9: .PP \fBTESTING\fP .PP Run the following commands one by one from a terminal on another linux machine against your own domain name. \fBsubstitute yourdomain.com in the examples below with your REAL domain name\fP .PP \fB\fCcurl \-A "googlebot" http://yourdomain.com\fR .PP Should respond with 200 OK .PP \fB\fCcurl \-A "80legs" http://yourdomain.com\fR .PP \fB\fCcurl \-A "masscan" http://yourdomain.com\fR .PP Should respond with: curl: (52) Empty reply from server .PP \fB\fCcurl \-I http://yourdomain.com \-e http://100dollars\-seo.com\fR .PP \fB\fCcurl \-I http://yourdomain.com \-e http://zx6.ru\fR .PP Should respond with: curl: (52) Empty reply from server .PP The Nginx Ultimate Bot Blocker is now WORKING and PROTECTING your web sites !!! .SH STEP 10: .PP \fBUPDATING THE NGINX BAD BOT BLOCKER\fP is now easy thanks to the automatic includes for whitelisting your own domain names. .PP Updating to the latest version is now as simple as: .PP \fB\fCcd /etc/nginx/conf.d\fR .PP \fB\fCsudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx\-ultimate\-bad\-bot\-blocker/master/conf.d/globalblacklist.conf\fR .PP \fB\fCsudo nginx \-t\fR .PP \fB\fCsudo service nginx reload\fR .PP \fBIn Alpine Linux you can run: /usr/sbin/updatenginxblocker\fP .PP And you will be up to date with all your whitelisted domains included automatically for you now. .SH AUTO UPDATING: .PP See my latest auto updater bash script at: .PP \[la]https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/updatenginxblocker.sh\[ra] .PP Relax now and sleep better at night knowing your site is telling all those baddies they are FORBIDDEN !!! .SH PULL REQUESTS: .PP To contribute your own bad referers please add them into the \[la]https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/blob/master/Pull_Requests_Here_Please/badreferers.list\[ra] file and then send a Pull Request (PR). .PP \fBAll additions will be checked for accuracy before being merged.\fP .SH ISSUES: .PP Log any issues regarding incorrect listings or any other problems on the issues system and they will be investigated and removed if necessary. I responde very quickly to user problems and have helped countless users for days on end to get their bot blocker working. You could say I am mad (disputable) but I love helping people and do not ignore issues or people with problems getting this to work.