一、Directory listings
修補方式:
編輯這個檔案/etc/apache2/apache2.conf。
sudo vi /etc/apache2/apache2.conf
找到這個內容:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
修改此行
Options Indexes FollowSymLinks
修改成
Options -Indexes +FollowSymLinks
重啟Apache2
sudo systemctl restart apache2
參考資料:
https://www.vultr.com/docs/how-to-disable-directory-browsing-on-apache
二、TLS 1.0 enabled
修補方式:
編輯這個 /etc/apache2/mods-available/ssl.conf 檔案。
找到以下此行設定,加入你不想要開放的,如SSL3.0、TLS1.0等。
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
重啟Apache2
sudo systemctl restart apache2
參考資料:
https://blog.ijun.org/2017/10/disable-tls-10-and-11-in-apache-24.html
三、Clickjacking: X-Frame-Options header missing
修補方式:
找到這個檔案/etc/apache2/conf-available/security.conf
將此行的註解取消
#Header set X-Frame-Options: “SAMEORIGIN”
取消後,執行此一指令
a2enmod headers
重啟Apache2
sudo systemctl restart apache2
參考資料:
http://programmer.hsinchi.info/1999
四、Cookies with missing, inconsistent or contradictory properties、Cookies without HttpOnly flag set、Cookies without Secure flag set
修補方式:
執行指令
a2enmod rewrite
a2enmod headers
編輯此一檔案/etc/apache2/apache2.conf
如果只跑HTTP,請加入此一行
Header edit Set-Cookie ^(.*)$ $1;HttpOnly
如果只跑HTTPS,請加入此一行
Header edit Set-Cookie ^(.*)$ $1;HttpOnly;Secure
重啟Apache2
sudo systemctl restart apache2
參考資料:
https://techexpert.tips/apache/apache-enable-httponly-secure-headers/
五、HTTP Strict Transport Security (HSTS) not implemented
修補方式:
a2enmod headers
修改/etc/apache2/sites-enabled/000-default-ssl.conf(請根據自已的環境更改檔案)
找到<VirtualHost *:443></VirtualHost> 這個區段,在其中加入這行設定:
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
參考資料:
https://websiteforstudents.com/lesson-39configure-http-strict-transport-security-hsts-on-apache2/