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

資料來源:



沒有留言:

張貼留言

Laravel 12 Model 資料庫中的資料表,並提供與資料庫互動的介面

相關系列文章: 1. 在 windows 10 安裝 laravel 12 studentManagement環境與設定 2. laravel 12 route 路由 3. laravel 12 Blade Templates 網頁模版 4. laravel 12 Control...