Files
42_105/README.md

2.7 KiB
Raw Blame History

CT105 — ip.lotimmy.com (echoip)

主機 192.168.42.105hostname CT105Ubuntu 24.04 LXC跑在 Proxmox 上。 對外提供一個 echoip 服務:回傳來訪者的 IP 與 GeoIP 資訊。

連線

設定在 ~/.ssh/config.d/timmy,皆內建 ProxyJump timmy_home_server(遠端免打 -J)。

ssh ct105          # User: timmy
ssh ct105-root     # User: root

內網直連(在 LAN 上時):ssh 192.168.42.105

  • root 與 timmy 皆已裝公鑰(~/.ssh/id_ecdsa.pub),免密碼。
  • sshd PermitRootLogin without-passwordroot 僅允許金鑰登入,密碼登入關閉。

服務鏈路

https://ip.lotimmy.com
   └─ Nginx Proxy Manager (Let's Encrypt 憑證, Public)
        └─ http://192.168.42.105:8080  (echoip 容器)
  • NPM 反代位置另一台主機NPM 管理介面proxy host ip.lotimmy.comhttp://192.168.42.105:8080
  • 反代帶 X-Real-IP 標頭echoip 以 -H X-Real-IP 信任之,故回傳的是真實外網 IP 而非反代內網 IP。

端點

URL 回傳
https://ip.lotimmy.com 純文字 IP
https://ip.lotimmy.com/json 完整 JSONIP + GeoIPcity/region/asn 等)

Docker 容器

兩個容器compose 檔在主機 /opt 下。

echoip — /opt/echoip/docker-compose.yml

services:
  echoip:
    image: mpolden/echoip
    container_name: echoip
    restart: unless-stopped
    ports:
      - "8080:8080"
    volumes:
      - /opt/geoip/GeoLite2-City.mmdb:/data/city.mmdb
      - /opt/geoip/GeoLite2-ASN.mmdb:/data/asn.mmdb
    command: -c /data/city.mmdb -a /data/asn.mmdb -H X-Real-IP
  • GeoIP 資料庫掛載自 /opt/geoip/
  • /opt/echoip/ 另有 GeoLite2 原始壓縮檔與 download_geolite2_databases.sh(更新 GeoIP 用)。

watchtower — /opt/watchtower/docker-compose.yml

services:
  watchtower:
    container_name: watchtower
    image: containrrr/watchtower
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    command: --cleanup --label-enable --interval 300
  • 每 5 分鐘檢查、清舊 image只更新有 com.centurylinklabs.watchtower.enable=true 標籤的容器

已知狀況

  • ⚠️ watchtower 開了 --label-enable,但 echoip 沒貼 com.centurylinklabs.watchtower.enable=true 標籤,所以 echoip 不會被自動更新watchtower 目前沒管任何容器)。 要啟用自動更新,在 echoip 的 compose 加:
      labels:
        - com.centurylinklabs.watchtower.enable=true
    
    然後 cd /opt/echoip && docker compose up -d

其他

  • 本機服務sshd:22、Postfix127.0.0.1:25、systemd-resolved本機 DNS。對外僅 echoip:8080。