Select Page
WordPress每天都被攻擊,關閉 XML-RPC 服務

WordPress每天都被攻擊,關閉 XML-RPC 服務

全世界隨時隨地都在發生攻擊事件,我這種小站每天也都有上千次的登入嘗試,實在是防不勝防,只能盡量減少被攻擊的機會,在wordpress中,可以先關閉 XML-RPC 就可以少掉9成的攻擊,值得看一下這篇

檢測自己的網站是否有 XML-RPC 服務

首先先測試自己的網站是否有開啟 XML-RPC 服務,可以透過以下 https://你的網址/xmlpc.php ,來檢測是否可以用,例如

https://rain.tips/xmlrpc.php

會看到下面的訊息,代表這個網址是可以工作的

XML-RPC server accepts POST requests only.

關閉 XMLRPC 的方法如下

1.RD,修改佈景主題的 function.php ,加入xmlrpc_enabled

add_filter('xmlrpc_enabled', '__return_false');

2.MIS,IIS和Apache

IIS 修改 web.config

<location path="xmlrpc.php">
<system.webServer>
  <security>
	<ipSecurity allowUnlisted="false">
	  <add ipAddress="127.0.0.1" subnetMask="255.255.255.255" allowed="true" />
	</ipSecurity>
  </security>
</system.webServer>
</location>

Apache 修改 .htaccess

<Files xmlrpc.php>
order deny,allow
deny from all
allow from 127.0.0.1
</Files>

3.Wordpress管理者

安裝外掛 Disable XML-RPC

參考資料
https://ithelp.ithome.com.tw/articles/10272566
IIS 下的 WordPress 如何移除 index.php 路徑

IIS 下的 WordPress 如何移除 index.php 路徑

很少人使用 IIS 架設 wordpress ,因為文件不好找,例外狀況又多,這次又發現 WordPress 的 Route 規則怪怪的,會在所有路徑中出現 index.php? ,這才意識到之前用 nginx 時候這些規則都早就解決,只要研究如何處理這樣的困境,研究之後得到有三個要點。

  • IIS 需要有 URL rewrite 擴充
  • WordPress 後台要去「設定->永久連結」設定自訂結構
  • WordPress 中的 web.config 需要加入 rewrite rule

先安裝 IIS 的 URL Rewrite
回到 WordPress 的後台設定永久連結
更改 web.config 設定 rewrite rule
	<rewrite>
		<rules>
			<rule name="WordPress: https://yourdomain.com" patternSyntax="Wildcard">
				<match url="*"/>
					<conditions>
						<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
						<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
					</conditions>
				<action type="Rewrite" url="index.php"/>
			</rule></rules>
    </rewrite>

Apache and Nginx 的設定作法

https://www.php.cn/cms/wordpress/459657.html