隐藏非公共资源,提高Wordpress的安全性


9

我是wordpress的新手,我想通过隐藏非公共资源来提高wordpress多站点的安全性。wp-admin,wp-config等

我的设置似乎可以使用,但是我不知道该设置是否会破坏某些功能(核心功能,流行的插件等)。

  1. 一般情况下我的设置好吗?
  2. 我的设置可以提高真正的安全性,或者我正在浪费时间?

httpd-vhosts.conf(Apache)

# Disallow public access php for .htaccess and .htpasswd files
<Files ".ht*">
    Require all denied
</Files>

# Disallow public access for *.php files in upload directory
<Directory "/htdocs/wp-content/uploads/">
   <Files "*.php">
       deny from all
   </Files>
</Directory>

# Disallow public access for... 
<Files "wp-config.php">
   order allow,deny
   deny from all
</Files>

<Files "readme.html">
   order allow,deny
   deny from all
</Files>

<Files "license.html">
   order allow,deny
   deny from all
</Files>

<Files "license.txt">
   order allow,deny
   deny from all
</Files>

# Because we do not use any remote connections to publish on WP
<Files "xmlrpc.php">
  order allow,deny
  deny from all
</Files>

.htaccess

RewriteEngine On
RewriteBase /

# List of ACME company IP Address
SetEnvIf Remote_Addr "^127\.0\.0\."      NETWORK=ACME
SetEnvIf Remote_Addr "^XX\.XX\.XX\.XX$"  NETWORK=ACME
SetEnvIf Remote_Addr "^XX\.XX\.XX\.XX$"  NETWORK=ACME
SetEnvIf Remote_Addr "^XX\.XX\.XX\.XX$"  NETWORK=ACME

# Disallow access to wp-admin and wp-login.php
RewriteCond %{SCRIPT_FILENAME} !^(.*)admin-ajax\.php$ # allow fo admin-ajax.php
RewriteCond %{ENV:NETWORK} !^ACME$ # allow for ACME
RewriteCond %{SCRIPT_FILENAME} ^(.*)?wp-login\.php$ [OR]
RewriteCond %{REQUEST_URI} ^(.*)?wp-admin\/
RewriteRule ^(.*)$ - [R=403,L]

# Block user enumeration
RewriteCond %{REQUEST_URI}  ^/$
RewriteCond %{QUERY_STRING} ^/?author=([0-9]*)
RewriteRule ^(.*)$ / [L,R=301]

# Block the include-only files.
# see: http://codex.wordpress.org/Hardening_WordPress (Securing wp-includes)
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
#RewriteRule ^wp-includes/[^/]+\.php$ - [F,L] # Comment for Multisite
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]

function.php

<?php
// Remove unnecessary meta tags
// <meta name="generator" content="WordPress 4.1" />
remove_action('wp_head', 'wp_generator');

// Disable WordPress Login Hints
function no_wordpress_errors(){
    return 'GET OFF MY LAWN !! RIGHT NOW !!';
}
add_filter( 'login_errors', 'no_wordpress_errors' );

wp-config.php

<?php
define('DISALLOW_FILE_EDIT', true);
define('DISALLOW_FILE_MODS', true);

3
如果您是新手并且不确定,请检查Sucuri Security,iThemes Security,Wordfence Security等插件...这些插件有多种选择。(不是我强迫您使用插件,但他们拥有坚实的用户群)
bravokeyl

Answers:


1

使用remove_action()可以删除不必要的链接,例如:

remove_action('wp_head', 'rsd_link'); //removes EditURI/RSD (Really Simple Discovery) link.
remove_action('wp_head', 'wlwmanifest_link'); //removes wlwmanifest (Windows Live Writer) link.
remove_action('wp_head', 'wp_generator'); //removes meta name generator.
remove_action('wp_head', 'wp_shortlink_wp_head'); //removes shortlink.
remove_action( 'wp_head', 'feed_links', 2 ); //removes feed links.
remove_action('wp_head', 'feed_links_extra', 3 );  //removes comments feed. 

1
发布代码时,请使用代码格式。
bravokeyl

-1

您正在cPanel上运行您的网站吗?

如果是这样,请浏览控制面板,您将看到一些很棒的模块。

  • 热链接保护
  • 水ech保护

在“ 高级”选项卡下,查找索引。单击后,您可以非常轻松地自定义和“隐藏非公开”资源。

在此处输入图片说明


热链接与安全性无关。您可以完全确保安全并允许进行热链接和“窃取”
Mark Kaplun

您认为该说法不正确。我真不敢相信我会发布多种优化技术。(facepalm)
Iroh叔叔

1
它是一个捂脸,如果你不知道:(优化和安全之间的区别。
马克·卡普伦
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.