Files
106_105_181_70/CLAUDE.md
2026-04-16 09:05:28 +08:00

54 lines
3.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Repository Nature
This repo is **infra/ops documentation + scripts** for the `tpesupporter.tpech.gov.tw` web server (106.105.181.70),不是應用程式原始碼。主要成品為 Markdown SOP、SSL 憑證素材與少量 shell 腳本。沒有 build/lint/test 流程。
`php/` 子目錄是**另一個獨立 git repo**(已 `.gitignore`),存放實際 PHP 應用程式(檢疫者心理量測與遠距諮詢系統),有自己的 `CLAUDE.md`。在本 repo 根目錄工作時,不要把 `php/` 內的檔案當成本 repo 的一部分修改或 commit。
## Remote-First Workflow
所有運行中的服務都在遠端,只能透過跳板機連線。核心拓撲:
```
本機 → jason_hsieh_home_srv (220.135.27.129:2022) → hospital_web (106.105.181.70)
→ hospital_media (106.105.181.40)
```
- `~/.ssh/config` 必須先設好(完整設定見 `ssh_config.md`),之後直接用 `ssh hospital_web` 即可。
- hospital_web 上的 docker-compose 專案位於 `/opt/php/`(即 `php/` 子目錄所對應的部署目標),但 repo 裡的 `php/` 並不是部署機制的一部分 — 不要假設本機改動會自動同步到遠端。
- 當 SSH config 生效時會自動建立 port forwardingNPM 管理後台在 `localhost:8181`、網頁 `localhost:8888`、Adminer `localhost:9090`、PHP 直連 `localhost:8001`
## SSL 憑證部署(主要維運工作)
網站 SSL 由遠端 Nginx Proxy Manager 管理但是以「Custom Certificate」方式手動掛檔 — 不是 NPM 自動續簽。完整 9 步 SOP 在 `ssl_deploy_guide.md`,務必照順序執行。幾個不容易從單一檔案看出的重點:
- 憑證素材放在本機 `ssl_certs/``privkey.pem``fullchain.pem` 已被 `.gitignore` 排除,不要誤 commit。
- 部署目標固定為遠端 `/opt/php/data/custom_ssl/npm-1/{fullchain.pem,privkey.pem}`,檔名不可改。
- 替換檔案後必須 `docker compose restart app`NPM 才會重新載入憑證。
- **NPM 後台顯示的到期日不會自動更新**Custom Certificate 的限制)。步驟 9 會透過 `docker exec` 進 NPM 容器,用內建 Python 直接 UPDATE `/data/database.sqlite``certificate` 表。新憑證部署完**一定要跑這一步**,否則後台會顯示錯誤到期日。
- 簽發單位是政府憑證管理中心GCA G3根憑證不在 Linux 預設信任庫,所以伺服器端 openssl 會顯示 `Verify return code: 20`。這是**正常現象**,瀏覽器端可正常驗證 — 不要把它當成部署失敗的訊號。
- `ssl_cert_note.md``ssl_deploy_guide.md` 底部都各有一份「憑證歷史紀錄」表,更換憑證後兩處都要同步更新。
## NPM 管理後台密碼重設
`reset_npm_password.sh` 直接在遠端用 `docker exec` 改 NPM 內建 sqlite 的 bcrypt hash重設為固定帳密 `admin@example.com / changeme`。腳本是設計成在 hospital_web 上執行(內含 `sudo docker exec nginxproxymanager ...`),不是本機執行。只在管理員密碼真的忘記時才用,重設後應立刻從 UI 改密碼。
## 遠端服務架構(速查)
`/opt/php/docker-compose.yml` 上的服務組合(詳見 `docker-compose-note.md`
```
Client → NPM (:80/:443, admin :81) → php (jc21 base, :8001→80)
→ adminer (:8080)
php ↔ memcached (:11211)
```
所有容器時區 `Asia/Taipei`;網頁檔掛在 `./html:/var/www/html`Let's Encrypt 目錄存在 `./letsencrypt`(但實際用的是 Custom Certificate見上
## 回應語言
與使用者互動一律使用繁體中文(台灣用語)。