A piece of Nginx configuration security reinforcement sharing code

Source: Internet
Author: User

The following is a piece of NGINX configuration code, which has a simple comment.
Everyone should remember the principle that the directory that can execute php programs must not allow read and write permissions, but the directory that can read and write (such as upload) must not be granted php Execution permissions.
 
 
This code section needs to be placed in the server segment (it is better to put it in front of location/{...}). You can also save it into a file and include it in each vhost.
 
 
 
 
#2011 (C) cnpanel
# Disable visitors without agent
If ($ http_user_agent ~ ^ $) {Return 412 ;}
# Disable possible Apache access files
Location ~ /\. Ht {deny all ;}
# Never can not visit or download files or DIRs starting #
Location ~ // # {Deny all ;}
# Disable risk request in some DIRs for secure
Location ~ */(Image | images | img | imgs | upload | uploads | upimg | upimgs | upfile | upfiles | down | download | downloads | attachment | attachments | js | css | style | styles | tpl | template | templates | theme | themes | view | views | lang | language | ages | setting | settings | app | apps | include | des | class | classes | mod | model | models | lib | libs | control | controls | source | sources | plugin | plugins | data | datas | database | tmp | temp | ipdata | html | avatar | avatars) /(. *)\. (php | php3 | php4 | php5 | cgi | asp | aspx | jsp | shtml | shtm | pl | cfm | SQL | mdb | dll | exe | com | inc | sh) $ {deny all ;}
 
 
 
 
Note. You can set the directory here if it is affected by the Directory of your program.
This is shared by netizens.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.