Các bạn có thể chèn các cấu hình bên dưới vào server { }
trong tập tin /etc/nginx/conf.d/default.conf
hoặc trong /usr/share/nginx/html/nginx.conf
nếu bạn theo hướng dẫn cài đặt LEMP trên CentOS 7 của mình.
# Vô hiệu hóa XML-RPC
location ~ xmlrpc.php { deny all; }
# Bảo vệ tập tin hệ thống
location = /wp-admin/install.php { deny all; }
location = /nginx.conf { deny all; }
location ~ /\.htaccess$ { deny all; }
location ~ /readme\.html$ { deny all; }
location ~ /readme\.txt$ { deny all; }
location ~ /wp-config.php$ { deny all; }
location ~ ^/wp-admin/includes/ { deny all; }
location ~ ^/wp-includes/[^/]+\.php$ { deny all; }
location ~ ^/wp-includes/js/tinymce/langs/.+\.php$ { deny all; }
location ~ ^/wp-includes/theme-compat/ { deny all; }
location ~ ^.*/\.git/.*$ { deny all; }
location ~ ^.*/\.svn/.*$ { deny all; }
# Vô hiệu hóa PHP ở mục Uploads
location ~ ^/wp\-content/uploads/.*\.(?:php[1-7]?|pht|phtml?|phps)$ { deny all; }
# Vô hiệu hóa PHP ở mục Plugins
location ~ ^/wp\-content/plugins/.*\.(?:php[1-7]?|pht|phtml?|phps)$ { deny all; }
# Vô hiệu hóa PHP ở mục Themes
location ~ ^/wp\-content/themes/.*\.(?:php[1-7]?|pht|phtml?|phps)$ { deny all; }
Lưu ý: Nếu bạn đăng sử dụng Solid Security thì trong chức năng đã có sẵn các cấu hình này.
Chúc các bạn thành công!
Bình Luận