Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report