# Global restrictions configuration file. # Designed to be included in any server {} block. location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) location ~ /\. { deny all; } # Restrict access to WordPress dashboard location /wp-admin { allow 127.0.0.1; allow Your_IP; deny all; } # Deny access to any files with a .php extension in the uploads directory # Works in sub-directory installs and also in multisite network # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) location ~* /(?:uploads|files)/.*\.php$ { deny all; } # Block PHP files in content directory. location ~* /wp-content/.*\.php\$ { deny all; } # Block PHP files in includes directory. location ~* /wp-includes/.*\.php\$ { deny all; } # Block PHP files in uploads, content, and includes directory. location ~* /(?:uploads|files|wp-content|wp-includes)/.*\.php\$ { deny all; } # Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS! location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)\$|^(\..*|Entries.*|Repository|Root|Tag|Template)\$|\.php_ { return 444; } #nocgi location ~* \.(pl|cgi|py|sh|lua)\$ { return 444; } #disallow location ~* (w00tw00t) { return 444; } location ~* /(\.|wp-config\.php|wp-config\.txt|changelog\.txt|readme\.txt|readme\.html|license\.txt) { deny all; } #Hide the nginx version. server_tokens off; #Hide the PHP version. fastcgi_hide_header X-Powered-By; proxy_hide_header X-Powered-By; autoindex off;