From 5a4ab39334a4ec4e4e673becd5064b66b408225e Mon Sep 17 00:00:00 2001 From: Timmy Date: Mon, 27 Apr 2026 11:37:01 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=96=B0=E5=A2=9E=E6=9C=AC=E6=A9=9F=20?= =?UTF-8?q?SSL=20=E6=86=91=E8=AD=89=E9=A9=97=E8=AD=89=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E8=AA=AA=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加內容: - hosts 檔案修改方法(推薦) - SwitchHosts 工具使用說明 - 指令行和瀏覽器驗證方法 - 完整操作步驟和注意事項 Co-Authored-By: Claude Sonnet 4 --- ssh_config.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/ssh_config.md b/ssh_config.md index 7f68e44..7f6211e 100644 --- a/ssh_config.md +++ b/ssh_config.md @@ -21,6 +21,7 @@ Host hospital_web # 端口轉發設定 LocalForward 8181 127.0.0.1:81 # NPM 管理後台 LocalForward 8888 127.0.0.1:80 # 網頁服務 + LocalForward 8443 127.0.0.1:443 # HTTPS 服務 LocalForward 9090 127.0.0.1:8080 # Adminer LocalForward 8001 127.0.0.1:8001 # PHP 容器 (直連) ``` @@ -37,5 +38,52 @@ Host hospital_web |---|---|---| | localhost:8181 | 127.0.0.1:81 | NPM 管理後台 | | localhost:8888 | 127.0.0.1:80 | 網頁服務 | +| localhost:8443 | 127.0.0.1:443 | HTTPS 服務 | | localhost:9090 | 127.0.0.1:8080 | Adminer | | localhost:8001 | 127.0.0.1:8001 | PHP 容器 (直連) | + +## 本機 SSL 憑證驗證 + +透過 SSH 端口轉發,可以在本機驗證 `tpesupporter.tpech.gov.tw` 的 SSL 憑證。 + +### 方法 1:修改 hosts 檔案(推薦) + +建立域名映射,讓瀏覽器可以正確驗證憑證: + +```bash +# 編輯 hosts 檔案 +sudo echo "127.0.0.1 tpesupporter.tpech.gov.tw" >> /etc/hosts +``` + +然後在瀏覽器中訪問: +``` +https://tpesupporter.tpech.gov.tw:8443 +``` + +**使用 SwitchHosts 工具:** +- 可下載 SwitchHosts 應用程式進行圖形化管理 +- 添加規則:`127.0.0.1 tpesupporter.tpech.gov.tw` +- 方便快速切換 hosts 設定 + +### 方法 2:指令行驗證 + +```bash +# 驗證憑證基本資訊 +echo | openssl s_client -connect localhost:8443 \ + -servername tpesupporter.tpech.gov.tw 2>/dev/null \ + | openssl x509 -noout -dates -subject -issuer + +# 檢查憑證鏈 +echo | openssl s_client -connect localhost:8443 \ + -servername tpesupporter.tpech.gov.tw 2>&1 \ + | grep 'Verify return code' +``` + +### 方法 3:瀏覽器忽略警告 + +直接訪問 `https://127.0.0.1:8443`,然後: +1. 點擊「進階」或「Advanced」 +2. 選擇「繼續前往 127.0.0.1」 +3. 可查看憑證詳細資訊 + +> **注意:** 使用方法 1 可獲得最佳的瀏覽器體驗,憑證驗證完全正常。