Files
headscale/config/config.yaml
timmy a20835c371 fix(compose): exec-form healthcheck; enable embedded DERP (tw)
- healthcheck 改 exec 形式(distroless 映像無 /bin/sh,CMD-SHELL 永遠 unhealthy)
- 補 command: serve、對外開 3478/udp(DERP STUN)
- config.yaml 內建 DERP 設為 enabled(region tw),與線上實跑一致

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-13 21:28:47 +08:00

250 lines
8.4 KiB
YAML
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.
---
# ============================================================================
# Headscale 設定檔
# 檔案搜尋順序:/etc/headscale → ~/.headscale → 當前工作目錄
# ============================================================================
# ----------------------------------------------------------------------------
# 伺服器與監聽位址
# ----------------------------------------------------------------------------
# server_url: 給客戶端連線用的網址
server_url: https://headscale.lotimmy.com
# listen_addr: Headscale HTTP API 綁定的 IP:Port
listen_addr: 0.0.0.0:8080
# metrics_listen_addr: Prometheus/監控系統抓取 metrics 的位址
metrics_listen_addr: 0.0.0.0:9090
# grpc_listen_addr: gRPC API 服務位址(給內部或管理工具使用)
grpc_listen_addr: 0.0.0.0:50443
# grpc_allow_insecure: 是否允許 gRPC 未加密連線(建議保持 false
grpc_allow_insecure: false
# unix_socket: 本地 UNIX Socket 路徑
unix_socket: /var/run/headscale/headscale.sock
# unix_socket_permission: UNIX Socket 權限設定
unix_socket_permission: "0770"
# ----------------------------------------------------------------------------
# Noise 加密協議
# ----------------------------------------------------------------------------
noise:
# private_key_path: Noise 私鑰路徑,缺少時會自動生成
private_key_path: /var/lib/headscale/noise_private.key
# ----------------------------------------------------------------------------
# IP 位址分配(必須位於 Tailscale 支援的範圍內)
# ----------------------------------------------------------------------------
prefixes:
# v4: IPv4 分配範圍(預設 100.64.0.0/10
v4: 100.64.0.0/10
# v6: IPv6 分配範圍(預設 fd7a:115c:a1e0::/48
v6: fd7a:115c:a1e0::/48
# allocation: 分配策略sequential 依序 / random 隨機)
allocation: sequential
# ----------------------------------------------------------------------------
# DERP 中繼伺服器(直連失敗時的備援通道)
# ----------------------------------------------------------------------------
derp:
server:
# enabled: 是否啟用內建 DERP需要 https/TLS
enabled: true
# region_id: 內建 DERP 區域 ID避免與其他 DERP 衝突)
region_id: 999
# region_code: 區域代碼(顯示於 Tailscale UI
region_code: "tw"
# region_name: 區域名稱(顯示於 Tailscale UI
region_name: "Headscale TW"
# stun_listen_addr: STUN 服務監聽位址(協助 NAT 穿透)
stun_listen_addr: "0.0.0.0:3478"
# private_key_path: 內建 DERP 私鑰路徑,缺少時自動生成
private_key_path: /var/lib/headscale/derp_server_private.key
# automatically_add_embedded_derp_region: 自動把內建 DERP 加進 DERP map
automatically_add_embedded_derp_region: true
# ipv4 / ipv6: 公開 IP改善 Exit-Node 或 DNS 問題時的連線穩定性)
ipv4: 125.229.110.50
ipv6: 2001:b011:3012:373a:be24:11ff:fe40:a31a
# urls: 外部可用的 DERP map JSON 清單
urls:
- https://controlplane.tailscale.com/derpmap/default
# paths: 本地 DERP map YAML 檔路徑(自建 DERP 伺服器使用)
paths: []
# auto_update_enabled: 自動定期更新 DERP map
auto_update_enabled: true
# update_frequency: DERP map 更新檢查頻率
update_frequency: 24h
# ----------------------------------------------------------------------------
# 資料庫
# ----------------------------------------------------------------------------
database:
# type: 資料庫類型sqlite / postgres建議 sqlite
type: sqlite
# debug: 啟用資料庫偵錯(需搭配 log.level=debug/trace
debug: false
gorm:
# prepare_stmt: 啟用 prepared statements
prepare_stmt: true
# parameterized_queries: 啟用參數化查詢(安全性與效能)
parameterized_queries: true
# skip_err_record_not_found: 略過「record not found」錯誤訊息
skip_err_record_not_found: true
# slow_threshold: 慢查詢閾值(毫秒)
slow_threshold: 1000
sqlite:
# path: SQLite 資料庫檔案路徑
path: /var/lib/headscale/db.sqlite
# write_ahead_log: 啟用 WAL 模式(正式環境建議開啟)
write_ahead_log: true
# wal_autocheckpoint: WAL 自動 checkpoint 閾值frame0 代表停用)
wal_autocheckpoint: 1000
# ----------------------------------------------------------------------------
# TLS / ACME 憑證
# ----------------------------------------------------------------------------
# acme_url: ACME 伺服器 URL預設 Let's Encrypt
acme_url: https://acme-v02.api.letsencrypt.org/directory
# acme_email: 註冊 ACME 憑證的聯絡 email
acme_email: ""
# tls_letsencrypt_hostname: 要申請憑證的網域名稱
tls_letsencrypt_hostname: ""
# tls_letsencrypt_cache_dir: 憑證與 metadata 存放路徑
tls_letsencrypt_cache_dir: /var/lib/headscale/cache
# tls_letsencrypt_challenge_type: ACME 驗證方式HTTP-01 或 TLS-ALPN-01
tls_letsencrypt_challenge_type: HTTP-01
# tls_letsencrypt_listen: HTTP-01 驗證監聽位址
tls_letsencrypt_listen: ":http"
# tls_cert_path / tls_key_path: 既有憑證路徑(不使用 Let's Encrypt 時填寫)
tls_cert_path: ""
tls_key_path: ""
# ----------------------------------------------------------------------------
# 日誌
# ----------------------------------------------------------------------------
log:
# format: 輸出格式text / json
format: text
# level: 日誌等級debug / info / warn / error
level: info
# logtail: 是否把 client 日誌送到 Tailscale 官方伺服器(預設關閉)
logtail:
enabled: false
# ----------------------------------------------------------------------------
# ACL 政策
# ----------------------------------------------------------------------------
policy:
# mode: ACL 儲存方式file / database
mode: file
# path: mode=file 時的 HuJSON 檔案路徑
path: /etc/headscale/policy.hujson
# ----------------------------------------------------------------------------
# DNS 與 MagicDNS
# ----------------------------------------------------------------------------
dns:
# magic_dns: 啟用 MagicDNS讓節點自動取得 hostname
magic_dns: true
# base_domain: MagicDNS 基底網域(須與 server_url 網域不同)
base_domain: internal.lotimmy.com
# override_local_dns: 是否強制 tailnet 節點使用以下 DNS覆蓋本地設定
# true → 所有節點強制走這組 DNS
# false → 保留各節點自己的 DNS例如公司 VPN、家用路由器內網
override_local_dns: true
# nameservers.global: 全域 DNS 伺服器清單
nameservers:
global:
# NextDNS個人 DoH Profile含封鎖清單與過濾規則
- https://dns.nextdns.io/9c7b19
# NextDNS 傳統 IPv4fallback
- 45.90.28.37
- 45.90.30.37
# Cloudflare DNS快速、穩定
- 1.1.1.1
- 1.0.0.1
- 2606:4700:4700::1111
- 2606:4700:4700::1001
- https://cloudflare-dns.com/dns-query
# Google DNS高穩定度 fallback
- https://dns.google/dns-query
# Quad9 DNS側重惡意網站過濾
- https://dns.quad9.net/dns-query
# nameservers.split: Split DNS針對特定網域指定 DNS
split: {}
# 範例:
# foo.bar.com:
# - 1.1.1.1
# darp.headscale.net:
# - 1.1.1.1
# - 8.8.8.8
# search_domains: 自訂搜尋網域(啟用 MagicDNS 時會自動加入 base_domain
search_domains: []
# extra_records: 額外 DNS 紀錄(目前僅支援 A 與 AAAA
# 詳見 docs/ref/dns.md
extra_records: []
# - name: "grafana.myvpn.example.com"
# type: "A"
# value: "100.64.0.3"
# extra_records_path: 額外 DNS 紀錄 JSON 檔案路徑(檔案變更時自動載入)
# extra_records_path: /var/lib/headscale/extra-records.json
# ----------------------------------------------------------------------------
# 其他雜項
# ----------------------------------------------------------------------------
# disable_check_updates: 停用 Headscale 啟動時自動檢查更新
disable_check_updates: false
# ephemeral_node_inactivity_timeout: 臨時節點閒置多久後自動刪除
ephemeral_node_inactivity_timeout: 30m
# randomize_client_port: 隨機選擇 WireGuard port預設 41641有助穿越嚴格防火牆
# randomize_client_port: # removed in new headscale; moved to policy file true