Skip to content

Commit 2a85a6f

Browse files
committed
Security: Block access to sensitive files in WordPress NGINX config
Added security blocks to prevent access to: • .git directories • Environment files (.env, .env.*) • Configuration/log files (.ini, .log, .conf, etc.) • Hidden files/directories (/.) All blocked requests return 403 Forbidden, with logging disabled to reduce noise. This hardens the WordPress installation against information disclosure attacks and unauthorized access to sensitive development/config files.
1 parent 0cbcc53 commit 2a85a6f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

rootfs/etc/nginx/host.conf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,30 @@ location ~ ^/(?:\.htaccess){
3232
deny all;
3333
}
3434

35+
location ~ /\.git {
36+
deny all;
37+
access_log off;
38+
log_not_found off;
39+
}
40+
41+
location ~ \.(env|env\..+)$ {
42+
deny all;
43+
access_log off;
44+
log_not_found off;
45+
}
46+
47+
location ~ \.(ini|log|conf|sql|yml|yaml|bak|config|dist|fla|psd|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl|xtmpl|bak|save|old|orig|template)$ {
48+
deny all;
49+
access_log off;
50+
log_not_found off;
51+
}
52+
53+
location ~ /\. {
54+
deny all;
55+
access_log off;
56+
log_not_found off;
57+
}
58+
3559
location = /wp-admin/install.php {
3660
deny all;
3761
}

0 commit comments

Comments
 (0)