在預設的 php 設定檔中,會將 expose_php 這個選項設定為 On

這樣預設會讓 http(s) 的回應 header 顯示 x-powered-by: [伺服器 or php 版本資訊],其實並沒有任何實質上的幫助

除此之外,還可能會導致惡意的使用者利用此版本資訊做進一步的攻擊。

如下圖:

未命名

移除此 header 的方法:

vim /etc/php5/apache2/php.ini    # 編輯 php.ini 設定檔

; 關閉 header 顯示 php 版本資訊
expose_php = Off

sudo service apache2 restart    # 重啟 apache,讓 apache 重新讀取 php 設定

這樣就可以移除掉 x-powered-by 這個敏感資訊的 header 囉!

 

參考資料:

http://stackoverflow.com/questions/2661799/removing-x-powered-by

Leave a Reply