2025年6月19日 星期四

Ubuntu 24.04 的 Apache2 設定 HTTP Strict Transport Security(HSTS)與檢測方法

1.啟用 apache headers 模組 
$sudo a2enmod headers

2.重新啟動 apache 
$sudo service apache2 restart

3.編輯 /etc/apache2/conf-available/security.conf ,加上 header 設定
$sudo nano /etc/apache2/conf-available/security.conf

    Header always set Strict-Transport-Security "max-age=31536000;includeSubdomains; preload"
步驟3.的方式會將整個設定複雜化,可以直接將
Header always set Strict-Transport-Security "max-age=31536000;includeSubdomains; preload"
寫入到/etc/apache2/sites-available/default-ssl.conf 。這樣設定會比較單純。所以
3.1 編輯 /etc/apache2/sites-available/default-ssl.conf

Header always set Strict-Transport-Security "max-age=31536000;includeSubdomains; preload"


4.重新載入設定 
$sudo service apache2 reload

5.檢測https://www.example.com.tw指令:
$curl -s -D - https://www.example.com.tw -o /dev/null

資料來源:



沒有留言:

張貼留言

Ubuntu 24.04 的 Apache2 解決 TLS/SSL Weak Cipher Suites

資安防護設定相關文章: 1. Laravel 網站遇到Host header attack 解決方法及python檢測漏洞方法 2. Ubuntu 24.04 的 Apache2 設定 HTTP Strict Transport Security(HSTS)與檢測方法 3. Ub...