Blocare ROBOTI cu NGINX [Anti DDOS]

Tutoriale Linux
Post Reply
User avatar
CryWolf
Sys Admin
Sys Admin
Posts: 443
Joined: Tue Dec 15, 2009 11:32 am
Detinator Steam: Da
Cunostinte CS: Excelente
Reputatie: Detinator
Webmaster
Scripter
Trance Fan
Location: Botosani
Contact:

Blocare ROBOTI cu NGINX [Anti DDOS]

Post by CryWolf »

Image
ENGLISH

Step 2: Install and Configure Nginx
If you haven't already installed Nginx, you can install it using your operating system's package manager. Once Nginx is installed, you can proceed with the configuration.

Step 3: Create a List of Bad Bots
Create a list of bad bots that you want to block. You can find publicly available lists of known bad bots online or compile your own based on your website's traffic patterns and security requirements.

Step 4: Create a New Configuration File
Create a new configuration file in the Nginx configuration directory (usually located at /etc/nginx/conf.d/ or /etc/nginx/sites-available/) to define rules for blocking bad bots. You can name the file something like block-bad-bots.conf.

Step 5: Configure Nginx to Block Bad Bots
Open the block-bad-bots.conf file with a text editor and add the following Nginx configuration directives:

nginx

Code: Select all

map $http_user_agent $bad_bot {
    default 0;
    ~*(bot1|bot2|bot3) 1;  # Add the list of bad bots here
}

Code: Select all

server {
    if ($bad_bot) {
        return 403;
    }
    # Add your regular server configuration here
}
In the above configuration:

The map directive defines a mapping between the HTTP user agent header and a variable called $bad_bot. If the user agent matches any of the specified bad bots, the variable $bad_bot is set to 1.
The server block contains an if statement that checks if the $bad_bot variable is set to 1. If it is, Nginx returns a 403 Forbidden response to the client.

Step 6: Test the Configuration
Before applying the configuration changes, test the Nginx configuration for syntax errors:

bash

Code: Select all

sudo nginx -t
If the test is successful, reload Nginx to apply the changes:

bash

Code: Select all

sudo systemctl reload nginx
Step 7: Monitor and Adjust
Monitor your server logs and website traffic to ensure that the bad bots are being blocked effectively. Periodically review and update your list of bad bots as needed.

That's it! You've successfully configured Nginx to block bad bots. This helps enhance the security and performance of your website by reducing unwanted traffic and potential security threats.
Info: NU IMI DATI PM PENTRU CERERI AJUTOR ETC (NU RASPUND) FOLOSITI FORUMUL.
Image

Image
CUM SA NU LUPTI PENTRU IUBIRE ????
Daca lupti,inseamna ca vrei sa castigi ceva.Iubirea nu-i o miza.
Post Reply