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

資料來源:



沒有留言:

張貼留言

在 192.168.91.x/24 網段,架設兩台DNS。當Master變更,讓client電腦對Slave 進行變更後的正解與反解-centos 7

系列文章: 1.在 Ubuntu 26.04 架設網域名稱伺服器(DNS)及相關設定說明 2.在 192.168.91.x/24 網段中,架設DNS,讓client電腦進行正解與反解-ubuntu 26.04 3. 在 192.168.91.x/24 網段,架設兩台DNS。當Ma...