wordpress-security.conf 2.5 KB

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