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