Get the App
SLTechnology News&Howtos  ›  Servers  › 

What are the four Nginx tips for setting up a server security environment?

Shulou Source: shulou.com Published: 2022-06-01 02:37:40 11月16日 Update

This article introduces you to set up the server security environment of the four Nginx tips are, the content is very detailed, interested friends can refer to, I hope you can help.

Share our commonly used WEB environment security skills, generally we use NGINX more, for general security we rarely go to other operations, basically the server or installation package comes with direct use.

First, it is prohibited to download files.

Some of our pages are easy to download and directly blocked.

Location. (zip | rar | sql | bak | gz | 7z) ${

Return 444

}

Second, shield spiders and reptiles

Some spider files slow down the website and block out the useless ones directly.

If ($http_user_agent ~ * (SemrushBot | python | MJ12bot | AhrefsBot | AhrefsBot | hubspot | opensiteexplorer | leiki | webmeup)) {

Return 444

}

Third, prohibit a certain directory from being executed.

In particular, the picture directory does not want to be uploaded some executable files.

# uploads | templets | data these directories prohibit the execution of PHP

Location ~ * ^ / (uploads | templets | data) /. *. (php | php5) ${

Return 444

}

Fourth, block IP or IP segments

# blocking the IP of 192.111.5.23

Deny 192.111.5.23

# Block 192.111.5.* this paragraph

Deny 192.111.5.0/24

This is generally used to solve the problem of directly blocking a certain IP when being attacked by a certain IP segment or IP.

In this way, add the above configuration file to the NGINX configuration file of the current website, and then restart NGINX to take effect.

This is the end of the four Nginx tips on setting up a server security environment. I hope the above can help you and learn more. If you think the article is good, you can share it for more people to see.

Tags: Files security skills servers environment services directories content more websites spiders help configuration good interest pictures guys buddies frequently used articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux OPPO Reno Huawei MariaDB Redmi