Apache 設定檔參數
Apache 所使用的版本及一些相關安全設定,本篇會記錄 Apache 相關會常用的參數
設定檔參數
- 全域設定上設定
vim /etc/apache2/apache2.conf
# 在此設定檔後面新增加三行參數
# 將 HTTP 回應標頭中的 Server 欄位簡化為單一產品名稱 Apache,不再帶出版本號或作業系統等額外資訊
ServerTokens Prod
# 關閉 Apache 在自動生成的錯誤頁面(如 404、500)與目錄清單頁尾所顯示的版本與伺服器資訊
ServerSignature Off
# 關閉 HTTP TRACE 方法,以防透過回顯洩漏少量內部資訊
TraceEnable Off
# 修改不顯示 Index of
<Directory />
# Options FollowSymLinks
# 不顯示 Index of
Options -Indexes +FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
# 不顯示 Index of
Options -Indexes +FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
# Options Indexes FollowSymLinks
# 不顯示 Index of
Options -Indexes +FollowSymLinks
AllowOverride None
Require all granted
</Directory>
- 預設設定檔
vim /etc/apache2/sites-available/000-default.conf
# 不顯示預設首頁
# 將 DirectoryIndex 改成不包含 index.html
DirectoryIndex disabled