基于Nginx的WordPress安全设置

共751个字

目录权限

最后更改文件所有人和组需要根据 nginx.conf 的设置来,有的是 www-data,有的是 nginx ,可自定义

实例:www 为网站目录

sudo chmod 755 www
##更改 www 目录为755权限

sudo find www -type d  -exec chmod 755 {} \;
##更改www目录下的所有文件夹为755权限

sudo find www -iname “*.php”  -exec chmod 644 {} \; 
##更改www目录下的所有php文件644权限 

sudo chown -R www-data:www-data  www

##更改 www 目录及目录下所有文件的所有者为www-data,组为 www-data

入口安全设置

在主题function.php文件中,加入以下代码(红色部分内容自定义)

add_action(‘login_enqueue_scripts’,’login_protection’);
function login_protection(){
if($_GET[‘xdd‘] != ‘1234567890‘)header(‘Location: /’);
}

然后可以用 /wp-login.php?xdd=1234567890 访问后台,如果觉得这样不便于记忆,可以在 nginx 上做一个 rewrite 规则

rewrite .*/123456789$ /wp-login.php?xdd=1234567890 last;
 

这样直接访问 你的域名/123456789 即可跳转到后台登录页面,直接访问 /wp-admin 会跳转到主页

禁止访问xmlrpc.php

在 sites-enabled 的站点设置文件里面加入一行

location ~* /xmlrpc.php {

                deny all;

直接访问 xmlrpc.php 返回 403 

 

❤ 喜欢 3411

6条回应:“基于Nginx的WordPress安全设置”

  1. It’s a shame you don’t have a donate button! I’d certainly donate to this excellent blog!
    I suppose for now i’ll settle for bookmarking and adding your RSS
    feed to my Google account. I look forward to brand new updates and will talk about this website with my Facebook group.
    Chat soon!

  2. gamefly说道:

    Oh my goodness! Impressive article dude! Thank you so much, However
    I am having troubles with your RSS. I don’t understand the reason why I can’t subscribe to it.

    Is there anybody else having the same RSS problems?

    Anybody who knows the answer can you kindly respond?
    Thanks!!

  3. WOW just what I was looking for. Came here by searching for
    gamefly

  4. Vidmcew说道:

    Today almost everyone visits YT or any other video hosting to upload and watch videos, free films and other video content. But sometimes you want to download a videofile and the service doesn’t allow you to do so. It’s where Vidmate is coming to help you. It helps you to download a video from may services, including Youtube, Facebook, Facebook and many other hosting services. To perform this you simply need to find a video and click download button. Plus, the Vidmate app is free of charge and easy in use! Download Vidmate app now and start downloading your favourite movies to share them with your family and friends!

  5. Superb blog! Do you have any recommendations for aspiring writers?
    I’m planning to start my own site soon but I’m a little lost on everything.
    Would you suggest starting with a free platform like WordPress or go for
    a paid option? There are so many options out there that I’m totally overwhelmed ..
    Any suggestions? Thanks a lot!

发表评论

必填项已用*标注

归档于 Ubuntu