Nginx Upload Directory configuration, prohibit execution permission

Source: Internet
Author: User

The easiest way to avoid execution permissions

The code is as follows: Copy code


Location ~ ^/Upload/. *. (php | php5) $
{
Deny all;
}

The above method could not meet my requirements. Later I found a good script.

The code is as follows: Copy code

Server
        {
Listen 80;
Server_name xxxx.com;
Index index.html index.htm index. php default.html default.htm default. php;
Root/home/wwwroot/xxxx.com;


Include none. conf;


# Matching multiple Upload directories
Location ~ ^/(Upload | Upload1)
                {
# The matching file contains at most two. More files
Location ~ "([.] {2,}) $"
                        {
Deny all;
                        }
# Configure php and php5 suffixes
Location ~ ". (Php | php5) $"
                        {
Deny all;
                        }
                }


Location ~ . *. (Php | php5 )? $
                {
Try_files $ uri = 404;
Fastcgi_pass unix:/tmp/php-cgi.sock;
Fastcgi_index index. php;
Fcinclude GI. conf;
                }


Location ~ . *. (Gif | jpg | jpeg | png | bmp | swf) $
                {
Expires 30d;
                }


Location ~ . *. (Js | css )? $
                {
Expires 12 h;
                }


Access_log off;
        }

Configure the dedecms directory in nginx to prohibit php from executing permissions.

The configuration is as follows:

The code is as follows: Copy code

Location ~ /Mm/(data | uploads | templets)/*. (php) $ {
Deny all;
}


Location ~ . Php $ {
Try_files $ uri/404.html;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
Includefagi_params;
}

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.