I. Restricting programs and file access based on extension
Use Nginx configuration to prohibit access to the PHP, Shell, Perl, Python program files under the upload Resource directory.
Configure Nginx to prohibit the resolution of the specified program under the specified directory.
Location ~ ^/images/.*\. (php|php5|sh|pl|py) ${deny all;} Location ~ ^/static/.*\. (php|php5|sh|pl|py) ${deny all;} Location ~ ^/data/(Attachment|avatar). *\. (PHP|PHP5) ${deny all;}
Restrictions on the above directory must be uninstalled before the PHP service configuration, as follows:
Placed in the Server tab: server { listen ; server_name www.dmtest.com; Location/{ root html; Index index.php index.html index.htm; } Location ~ ^/images/.*\. (php|php5|sh|pl|py) $ { deny all; } Location ~ ^/static/.*\. (php|php5|sh|pl|py) $ { deny all; } Location ~ ^/data/(Attachment|avatar). *\. (PHP|PHP5) $ { deny all; } ............}
Nginx Site directory and file URL access control