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