天天看點

如何隐藏 Apache 版本号和其它敏感資訊

這允許在伺服器生成的文檔(如錯誤消息、modproxy 的 ftp 目錄清單、modinfo 輸出等等)下添加一個顯示伺服器名稱和版本号的頁腳行。

它有三個可能的值:

<code>on</code> - 允許在伺服器生成的文檔中添加尾部頁腳行,

<code>off</code> - 禁用頁腳行

<code>email</code> - 建立一個 “mailto:” 引用;用于将郵件發送到所引用文檔的 serveradmin。

<a target="_blank"></a>

它決定了發送回用戶端的伺服器響應頭字段是否包含伺服器作業系統類型的描述和有關已啟用的 apache 子產品的資訊。

此指令具有以下可能的值(以及在設定特定值時發送到用戶端的示例資訊):

<code>servertokens full (或者不指定)</code>

發送給用戶端的資訊: <code>server: apache/2.4.2 (unix) php/4.2.2 mymod/1.2</code>

<code>servertokens prod[uctonly]</code>

發送給用戶端的資訊: <code>server: apache</code>

<code>servertokens major</code>

發送給用戶端的資訊: <code>server: apache/2</code>

<code>servertokens minor</code>

發送給用戶端的資訊: <code>server: apache/2.4</code>

<code>servertokens min[imal]</code>

發送給用戶端的資訊:<code>server: apache/2.4.2</code>

<code>servertokens os</code>

發送給用戶端的資訊: <code>server: apache/2.4.2 (unix)</code>

注意:在 apache 2.0.44 之後,<code>servertokens</code> 也控制由 <code>serversignature</code> 指令提供的資訊。

為了隐藏 web 伺服器版本号、伺服器作業系統細節、已安裝的 apache 子產品等等,使用你最喜歡的編輯器打開 apache 配置檔案:

<code>$ sudo vi /etc/apache2/apache2.conf #debian/ubuntu systems</code>

<code>$ sudo vi /etc/httpd/conf/httpd.conf #rhel/centos systems</code>

添加/修改/附加下面的行:

<code>servertokens prod</code>

<code>serversignature off</code>

儲存并退出檔案,重新開機你的 apache 伺服器:

<code>$ sudo systemctl apache2 restart #systemd</code>

<code>$ sudo sevice apache2 restart #sysvinit</code>

本篇中,我們解釋了如何使用特定的 apache 指令隐藏apache web 伺服器版本号及其他資訊。

原文釋出時間為:2017-02-05

本文來自雲栖社群合作夥伴“linux中國”