X-Powered-By

所以我說 X-Powered-By 這個 header 到底是什麼?為什麼大家都想把它 disabled 掉呢?

今天在看 Next.js 的官方文件時,發現有 X-Powered-By 這個 header,但文件裡也只有說明把這個 header disabled 掉的方法,並沒有說明為什麼,本來以為 Google 後可以馬上找到答案,殊不知只是查到各種 application framework disable 這個 header 的方法。

1. X-Powered-By 這個 header 透露了什麼資訊?

點到搜尋結果的第二頁才有維基百科的說明:

表明用於支援當前網頁應用程式的技術

簡而言之,大部分的 Application framework 會自動在 response 加上 X-Powered-By 這個 header,透露這個 application 使用了什麼樣的框架甚至版本。

2. 沒有 Disable X-Powered-By 會有什麼風險?

如果沒有 disable X-Powered-By header 的話,任何發出 request 的人,都可以知道你使用的網頁框架或是技術甚至版本,如此一來就可以透過 CVE (Common Vulnerabilities and Exposures – 收集各種資安弱點及漏洞的資料庫),來查詢你正在使用的框架版本有的資安漏洞,利用此漏洞來攻擊你的網站。

3. 各種 Disable X-Powered-By 的方法

整理一下查到的 disable X-Powered-By 的方法:

3.1 Framework

Express.js: 如何刪除X-Powered-By:Express – camel ‘s blog
Next.js: next.config.js: Disabling x-powered-by
ASP.NET Core: ASP.NET Core 教學- 移除Response Header 資訊
php: [php] 移除x-powered-by 伺服器與php 資訊

3.2 Web Server

IIS: 徹底移除IIS Response Header 版本資訊 – 黑暗執行緒
NginX: Hide X-Powered-By (nginx)
Apache: 在apache關閉X-Powered-By的方法 – 一些平鋪直敘技術相關文

4. 參考資料

公共漏洞和暴露- 維基百科,自由的百科全書
在HTTP请求的header头里面,为什么有的时候有X-Powered-By这个值,有的时候没有呢?
What does “x-powered by” mean?

如果覺得我的文章有幫助的話,歡迎幫我的粉專按讚哦~謝謝你!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top