Nginx Upload directory configuration, prohibit execute permission

Source: Internet
Author: User

We often put the site's image file upload directory is set to upload files only can not execute the file, that is, to prohibit the execution of permissions, small part to give you an upload directory configuration, prohibit the implementation of permission methods, you can refer to.

If you don't have the simplest way to execute permissions

The code is as follows Copy Code


Location ~ ^/upload/.*. (PHP|PHP5) $
{
Deny all;
}

The above method can not meet my requirements, and then 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;


#匹配多个上传目录
Location ~ ^/(upload| UPLOAD1)
{
# The matching file has a maximum name of two. above 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;
Include fcgi.conf;
}


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


Location ~. *. (JS|CSS)? $
{
Expires 12h;
}


Access_log off;
}

Nginx prohibit dedecms directory PHP execution permissions configuration method.

You can configure the following:

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;
Includefastcgi_params;
}

Nginx Upload directory configuration, prohibit execute permission

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.