|
| 1 | +# Nginx UI Template Start |
| 2 | +name = "WordPress Security" |
| 3 | +author = "@sanvu88" |
| 4 | +description = { en = "WordPress Security Config", vi_VN = "Cấu hình bảo mật cho WordPress"} |
| 5 | + |
| 6 | +[variables.blockUserAPI] |
| 7 | +type = "boolean" |
| 8 | +name = { en = "Block WordPress User API", vi_VN = "Chặn truy cập danh sách user"} |
| 9 | +value = true |
| 10 | + |
| 11 | +[variables.blockXMLRPC] |
| 12 | +type = "boolean" |
| 13 | +name = { en = "Block WordPress XMLRPC", vi_VN = "Chặn truy cập xmlrpc.php"} |
| 14 | +value = true |
| 15 | +# Nginx UI Template End |
| 16 | + |
| 17 | +{{- if .blockUserAPI }} |
| 18 | +location ~* /wp-json/wp/v2/users { |
| 19 | + return 444; |
| 20 | +} |
| 21 | +{{- end }} |
| 22 | + |
| 23 | +{{- if .blockXMLRPC }} |
| 24 | +location = /xmlrpc.php { |
| 25 | + return 444; |
| 26 | +} |
| 27 | +{{- end }} |
| 28 | + |
| 29 | +location ~* wp-admin/includes { return 444; } |
| 30 | +location ~* wp-includes/theme-compat { return 444; } |
| 31 | + |
| 32 | +location /wp-includes/ { |
| 33 | + location ~ \.(gz|tar|bzip2|7z|php|php5|php7|log|error|py|pl|kid|love|cgi|shtml|phps|pht|jsp|asp|sh|bash)$ { |
| 34 | + access_log off; |
| 35 | + log_not_found off; |
| 36 | + return 444; |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +location /wp-content/uploads/ { |
| 41 | + location ~ \.(gz|tar|bzip2|7z|php|php5|php7|log|error|py|pl|kid|love|cgi|shtml|phps|pht|jsp|asp|sh|bash)$ { |
| 42 | + access_log off; |
| 43 | + log_not_found off; |
| 44 | + return 444; |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +location /wp-content/cache/ { |
| 49 | + location ~ \.(php|php5|php7|log|error|py|pl|kid|love|cgi|shtml|phps|pht|jsp|asp|sh|bash)$ { |
| 50 | + access_log off; |
| 51 | + log_not_found off; |
| 52 | + return 444; |
| 53 | + } |
| 54 | +} |
| 55 | + |
| 56 | +location /wp-content/plugins/ { |
| 57 | + location ~ \.(htm|shtml|php|swf|phps|pht|log|error|py|pl|kid|love|cgi|jsp|asp|sh|bash)$ { |
| 58 | + access_log off; |
| 59 | + log_not_found off; |
| 60 | + return 444; |
| 61 | + } |
| 62 | +} |
| 63 | + |
| 64 | +location /wp-content/plugins/onesignal-free-web-push-notifications/ { |
| 65 | + access_log off; |
| 66 | + log_not_found off; |
| 67 | + allow all; |
| 68 | +} |
| 69 | + |
| 70 | +location /wp-content/updraft/ { |
| 71 | + access_log off; |
| 72 | + log_not_found off; |
| 73 | + return 444; |
| 74 | +} |
| 75 | + |
| 76 | +location /wp-content/backups-dup-pro/ { |
| 77 | + access_log off; |
| 78 | + log_not_found off; |
| 79 | + return 444; |
| 80 | +} |
| 81 | + |
| 82 | +location /wp-snapshots/ { |
| 83 | + access_log off; |
| 84 | + log_not_found off; |
| 85 | + return 444; |
| 86 | +} |
| 87 | + |
| 88 | +location /wp-content/uploads/sucuri/ { |
| 89 | + access_log off; |
| 90 | + log_not_found off; |
| 91 | + return 444; |
| 92 | +} |
| 93 | + |
| 94 | +location /wp-content/uploads/nginx-helper/ { |
| 95 | + access_log off; |
| 96 | + log_not_found off; |
| 97 | + return 444; |
| 98 | +} |
| 99 | + |
| 100 | +location ~* ^/(?:wp-links-opml\.php|wp-config\.php|wp-config-sample\.php|readme\.html|license\.txt)$ { |
| 101 | + access_log off; |
| 102 | + log_not_found off; |
| 103 | + return 444; |
| 104 | +} |
0 commit comments