Files
nginx-proxy-manager/README.md

156 lines
8.2 KiB
Markdown
Raw Permalink 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.
# Nginx Proxy Manager (192.168.42.124)
家用反向代理閘道。所有對外網域先進到這台,再轉到內網各服務。
- **主機**`192.168.42.124`,部署路徑 `/opt/nginx-proxy-manager`
- **管理介面**http://192.168.42.124:81 或 https://ngx-proxy-mgr.lotimmy.com
- **版本**NPM 2.15.1image `jc21/nginx-proxy-manager:latest`2026-06-03 建立)
- **狀態**:容器 `nginxproxymanager` 已連續運行 5 週,佔用 80 / 81 / 443
> 本文件為 2026-08-01 的現況快照,資料來自主機上的 `docker-compose.yml` 與 `data/database.sqlite`。
> 操作方式新增服務、刪除、API 用法、踩過的坑)見 [NOTES.md](NOTES.md)。
## 部署
`docker-compose.yml`(單一服務):
| 項目 | 設定 |
|---|---|
| image | `jc21/nginx-proxy-manager:latest` |
| container_name | `nginxproxymanager` |
| restart | `unless-stopped` |
| ports | `80:80``443:443``81:81` |
| volumes | `./data:/data``./letsencrypt:/etc/letsencrypt` |
| env | `TZ=Asia/Taipei``DISABLE_IPV6` 已註解保留) |
| dns | `8.8.8.8``1.1.1.1` |
| labels | `com.centurylinklabs.watchtower.enable=true`watchtower 自動更新) |
目錄裡的 `Makefile` 包好了常用指令,專案名自動取當前資料夾名:
```bash
make up # 背景啟動
make down # 停止並移除容器
make restart # 重啟
make logs # tail -f 最後 100 行
make ps # 服務狀態
make exec # 進入 app 容器 shell
make clean # 連 volume 一起清掉(危險)
```
## 資料
```
/opt/nginx-proxy-manager/
├── docker-compose.yml
├── Makefile
├── data/ # 193M
│ ├── database.sqlite # 所有設定都在這
│ ├── database.sqlite.bak-2026-04-18
│ ├── keys.json # JWT 金鑰,遺失等於所有 session 失效
│ ├── nginx/ # NPM 產生的 confproxy_host / dead_host / stream / …)
│ ├── custom_ssl/ access/ logs/ letsencrypt-acme-challenge/
└── letsencrypt/ # 7.4MLet's Encrypt 憑證本體
```
備份只要打包 `data/``letsencrypt/` 兩個目錄即可完整還原。目前只有一份 2026-04-18 的手動 DB 備份,**沒有排程備份**。
## 物件統計
| 類型 | 數量 |
|---|---|
| Proxy Host | 36全部啟用 |
| Certificate | 40全為 Let's Encrypt |
| Dead Host | 2`*.lotimmy.com``125.229.110.50` |
| Access List | 1`Protect PACS` |
| Redirection Host / Stream | 0 |
| User | 1 |
## Proxy Host 一覽
旗標說明:`cache` 快取、`block` block common exploits、`ws` websocket upgrade、`h2` HTTP/2。
| 網域 | 轉發目標 | SSL | 旗標 |
|---|---|---|---|
| bark.lotimmy.com | http://192.168.42.116:8080 | SSL | block ws h2 |
| codimd.lotimmy.com | http://192.168.42.120:30921 | 強制 | h2 |
| dicom-server.lotimmy.com | http://192.168.42.124:60606 | SSL | block ws |
| drawnix.timmy.edu.kg | http://192.168.42.124:40000 | SSL | block ws h2 |
| gitea.timmy.edu.kg | http://192.168.42.124:31337 | 強制 | block ws h2 |
| headscale.lotimmy.com | http://192.168.42.126:8080 | SSL | cache block ws h2 |
| hoarder.lotimmy.com | http://192.168.42.124:3000 | SSL | block ws h2 |
| httpbin.lotimmy.com | http://192.168.42.120:30921 | SSL | cache block ws h2 |
| ip.lotimmy.com | http://192.168.42.105:8080 | SSL | block ws h2 |
| lyd-biz.lotimmy.com | http://192.168.42.117:5000 | SSL | block ws h2 |
| lyd-biz-test.lotimmy.com | http://192.168.42.115:5000 | SSL | block ws h2 |
| mailpit.lotimmy.com | http://192.168.42.107:8025 | SSL | block ws h2 |
| myspeed.timmy.edu.kg | http://192.168.42.124:5216 | SSL | ws h2 |
| netbird.timmy.us.kg | http://192.168.42.127:80 | 強制 | block ws h2 |
| ngx-proxy-mgr.lotimmy.com | http://192.168.42.124:81 | SSL | block ws h2 |
| noco.timmy.edu.kg | http://192.168.42.124:28080 | SSL | cache block ws h2 |
| ollama.lotimmy.com | http://100.64.0.30:11434 | SSL | — |
| opengist.lotimmy.com | http://192.168.42.120:30921 | 強制 | block ws h2 |
| openwrt.lotimmy.com | http://192.168.42.10:80 | SSL | cache block ws h2 |
| pacs.lotimmy.com | http://192.168.42.124:8042 | SSL | block ws |
| pb.lotimmy.com | http://192.168.42.124:18090 | 強制 | block ws h2 |
| pbs.lotimmy.com | https://192.168.42.30:8007 | 強制 | block ws |
| pdf.lotimmy.com | http://192.168.42.109:8080 | SSL | block ws h2 |
| picsur.lotimmy.com | http://192.168.42.124:8080 | SSL | cache block ws h2 |
| pogo-viewer.timmy.us.kg | http://192.168.42.108:8028 | SSL | cache block ws h2 |
| poke-api.lotimmy.com | http://192.168.42.108:8008 | SSL | block |
| prompt-opt.lotimmy.com | http://192.168.42.124:8082 | SSL | block ws |
| pve.lotimmy.com | https://192.168.42.38:8006 | 強制 | block ws h2 |
| registry.lotimmy.com | http://192.168.42.124:5000 | SSL | block ws |
| registry-ui.lotimmy.com | http://192.168.42.124:8081 | SSL | — |
| syno.lotimmy.com | https://192.168.42.20:5001 | 強制 | block ws h2 |
| tinyauth.lotimmy.com | http://192.168.42.124:3005 | 強制 | ws h2 |
| tinyauth.timmy.edu.kg | http://192.168.42.124:3006 | 強制 | ws h2 |
| ucapi.timmy.edu.kg | http://192.168.42.108:16888 | SSL | block ws h2 |
| vaultwarden.lotimmy.com | http://192.168.42.120:30921 | 強制 | ws h2 |
| web.lotimmy.com | http://192.168.42.104:80 | SSL | block ws h2 |
### 後端主機分布
| 後端 | 用途 |
|---|---|
| `192.168.42.124`(本機) | 12 個服務dicom-server、drawnix、gitea、hoarder、myspeed、noco、pacs、pb、picsur、prompt-opt、registry(+ui)、tinyauth ×2、NPM 自己 |
| `192.168.42.120:30921` | 4 個網域共用K8s NodePortcodimd、httpbin、opengist、vaultwarden |
| `192.168.42.108` | poke-api、pogo-viewer、ucapi |
| `192.168.42.30` / `.38` / `.20` | PBS / PVE / Synology皆為 https 後端) |
| `100.64.0.30` | ollama走 Tailscale/Headscale 網段 |
## 憑證
40 張全部由 Let's Encrypt 簽發。以到期日排序,需要注意的是前段:
| 憑證 | 到期日 | 狀況 |
|---|---|---|
| ~~typebot.lotimmy.com~~ | 2025-10-02 | 2026-08-01 已刪除DB + certbot |
| myip.lotimmy.com | 2026-02-09 | **已過期**,無對應 proxy host |
| pangolin.timmy.edu.kg | 2026-02-22 | **已過期**,無對應 proxy host |
| minio.lotimmy.com | 2026-05-28 | **已過期**,無對應 proxy host |
| ~~jsbin.timmy.edu.kg~~ | 2026-08-09 | 2026-08-01 已刪除DB + certbot |
| auth.lotimmy.com | 2026-08-20 | 無對應 proxy host |
| mailpit.lotimmy.com | 2026-09-01 | 使用中 |
| …其餘 34 張 | 2026-09 ~ 2026-10 | 使用中,正常續期 |
| gitea.timmy.edu.kg (npm-88) | 2026-10-30 | 2026-08-01 新簽 |
已移除的憑證(連同 `live` / `archive` / `renewal` 檔案,皆以 `certbot delete` 清除):
| 憑證 | 移除日期 | 原因 |
|---|---|---|
| jsbin.timmy.edu.kg (npm-79) | 2026-08-01 | 孤兒憑證proxy host 早已刪除 |
| typebot.lotimmy.com (npm-49) | 2026-08-01 | 孤兒憑證2025-10-02 就過期 |
| n8n.lotimmy.com (npm-45) | 2026-08-01 | 服務下線,連同 proxy host 一併移除 |
`letsencrypt/live/` 底下有 `npm-1` ~ `npm-87` 的斷號目錄,部分帶 `-0001` 後綴(同網域重簽產生的新 lineage。舊 lineage 不會自動清掉,目錄數量比實際憑證多屬正常。
## 待辦 / 觀察
- **剩 4 張孤兒憑證**myip、pangolin、minio、auth已無 proxy host 使用,其中 3 張過期。可在 UI 的 SSL Certificates 刪掉。
- `letsencrypt/` 底下還有一批 DB 已軟刪除、但檔案還在的舊 lineage例如 `npm-4`2025 年 n8n 的舊憑證)。不影響運作,佔用也小,要清再說。
- **沒有自動備份**。`data/` + `letsencrypt/` 打包丟到別台就夠,目前有 2026-04-18 與 2026-08-01 兩份手動 DB 備份。
- **watchtower 自動更新已開啟** 且 image tag 是 `latest`NPM 大版本更新會直接套用DB migration 失敗時沒有回退點——這是上一點更要緊的原因。
- **單點故障**36 個網域全靠這台,其中 12 個服務也跑在同一台上。
- **Gitea 的 `ROOT_URL` 仍是 `http://192.168.42.124:31337/`**,所以 UI 顯示的 clone URL、通知信連結都還是舊的 IP:port。要改 `app.ini``[server] ROOT_URL = https://gitea.timmy.edu.kg/` 並重啟 Gitea。
- `dead_host``*.lotimmy.com` 泛用攔截,未定義的子網域會落到這裡,不會外洩到預設站台。