This commit is contained in:
awei
2025-06-15 17:13:26 +08:00
parent 21f4026106
commit cb8fe9f52e
11 changed files with 153 additions and 210 deletions

View File

@@ -1,113 +1,58 @@
---
# headscale will look for a configuration file named `config.yaml` (or `config.json`) in the following order:
#
# - `/etc/headscale`
# - `~/.headscale`
# - current working directory
# - 当前工作目录
# The url clients will connect to.
# Typically this will be a domain like:
#
# https://myheadscale.example.com:443
#
# 服务端URL客户端将连接到的地址
server_url: http://0.0.0.0:8080
# Address to listen to / bind to on the server
#
# For production:
# 服务监听地址
listen_addr: 0.0.0.0:8080
#isten_addr: 127.0.0.1:8080
# Address to listen to /metrics, you may want
# to keep this endpoint private to your internal
# network
#
# 指标监听地址(建议保持内网访问)
metrics_listen_addr: 127.0.0.1:9090
# Address to listen for gRPC.
# gRPC is used for controlling a headscale server
# remotely with the CLI
# Note: Remote access _only_ works if you have
# valid certificates.
#
# For production:
# gRPC监听地址用于远程CLI控制
grpc_listen_addr: 0.0.0.0:50443
#rpc_listen_addr: 127.0.0.1:50443
# Allow the gRPC admin interface to run in INSECURE
# mode. This is not recommended as the traffic will
# be unencrypted. Only enable if you know what you
# are doing.
# 允许不安全的gRPC连接不建议生产环境使用
grpc_allow_insecure: true
# The Noise section includes specific configuration for the
# TS2021 Noise protocol
# Noise协议配置
noise:
# The Noise private key is used to encrypt the
# traffic between headscale and Tailscale clients when
# using the new Noise-based protocol.
# 噪声协议私钥路径
private_key_path: /var/lib/headscale/noise_private.key
# List of IP prefixes to allocate tailaddresses from.
# Each prefix consists of either an IPv4 or IPv6 address,
# and the associated prefix length, delimited by a slash.
# It must be within IP ranges supported by the Tailscale
# client - i.e., subnets of 100.64.0.0/10 and fd7a:115c:a1e0::/48.
# See below:
# IPv6: https://github.com/tailscale/tailscale/blob/22ebb25e833264f58d7c3f534a8b166894a89536/net/tsaddr/tsaddr.go#LL81C52-L81C71
# IPv4: https://github.com/tailscale/tailscale/blob/22ebb25e833264f58d7c3f534a8b166894a89536/net/tsaddr/tsaddr.go#L33
# Any other range is NOT supported, and it will cause unexpected issues.
# IP地址分配前缀
prefixes:
v4: 100.64.0.0/10
v6: fd7a:115c:a1e0::/48
# Strategy used for allocation of IPs to nodes, available options:
# - sequential (default): assigns the next free IP from the previous given IP.
# - random: assigns the next free IP from a pseudo-random IP generator (crypto/rand).
# IP分配策略sequential顺序或 random随机
allocation: sequential
# DERP is a relay system that Tailscale uses when a direct
# connection cannot be established.
# https://tailscale.com/blog/how-tailscale-works/#encrypted-tcp-relays-derp
#
# headscale needs a list of DERP servers that can be presented
# to the clients.
# DERP中继服务器配置
derp:
server:
# If enabled, runs the embedded DERP server and merges it into the rest of the DERP config
# The Headscale server_url defined above MUST be using https, DERP requires TLS to be in place
# 启用内置DERP服务器
enabled: true
# Region ID to use for the embedded DERP server.
# The local DERP prevails if the region ID collides with other region ID coming from
# the regular DERP config.
# 区域ID避免与公共DERP区域冲突
region_id: 999
# Region code and name are displayed in the Tailscale UI to identify a DERP region
# 区域代码和名称显示在客户端UI中
region_code: "headscale"
region_name: "Headscale Embedded DERP"
# Listens over UDP at the configured address for STUN connections - to help with NAT traversal.
# When the embedded DERP server is enabled stun_listen_addr MUST be defined.
#
# For more details on how this works, check this great article: https://tailscale.com/blog/how-tailscale-works/
# STUN服务监听地址用于NAT穿透
stun_listen_addr: "0.0.0.0:3478"
# Private key used to encrypt the traffic between headscale DERP
# and Tailscale clients.
# The private key file will be autogenerated if it's missing.
#
# DERP服务器私钥路径
private_key_path: /var/lib/headscale/derp_server_private.key
# This flag can be used, so the DERP map entry for the embedded DERP server is not written automatically,
# it enables the creation of your very own DERP map entry using a locally available file with the parameter DERP.paths
# If you enable the DERP server and set this to false, it is required to add the DERP server to the DERP map using DERP.paths
# 自动添加内置DERP区域到DERP映射
automatically_add_embedded_derp_region: true
# For better connection stability (especially when using an Exit-Node and DNS is not working),
# it is possible to optionally add the public IPv4 and IPv6 address to the Derp-Map using:
ipv4: 1.2.3.4
ipv6: 2001:db8::1
# 公网IPv4/IPv6地址提高连接稳定性
ipv4: 47.239.121.24
# ipv6: 2001:db8::1
# List of externally available DERP maps encoded in JSON
# urls:
@@ -149,29 +94,16 @@ database:
# GORM configuration settings.
gorm:
# Enable prepared statements.
prepare_stmt: true
# Enable parameterized queries.
parameterized_queries: true
# Skip logging "record not found" errors.
skip_err_record_not_found: true
# Threshold for slow queries in milliseconds.
slow_threshold: 1000
prepare_stmt: true # 启用预处理语句
parameterized_queries: true # 启用参数化查询
skip_err_record_not_found: true # 跳过"记录未找到"错误
slow_threshold: 1000 # 慢查询阈值(毫秒)
# SQLite config
sqlite:
path: /var/lib/headscale/db.sqlite
# Enable WAL mode for SQLite. This is recommended for production environments.
# https://www.sqlite.org/wal.html
write_ahead_log: true
# Maximum number of WAL file frames before the WAL file is automatically checkpointed.
# https://www.sqlite.org/c3ref/wal_autocheckpoint.html
# Set to 0 to disable automatic checkpointing.
wal_autocheckpoint: 1000
write_ahead_log: true # 启用WAL模式生产推荐
wal_autocheckpoint: 1000 # WAL自动检查点阈值
# # Postgres config
# Please note that using Postgres is highly discouraged as it is only supported for legacy reasons.
@@ -277,10 +209,8 @@ dns:
# List of DNS servers to expose to clients.
nameservers:
global:
- 1.1.1.1
- 1.0.0.1
- 2606:4700:4700::1111
- 2606:4700:4700::1001
- 114.114.114.114
# NextDNS (see https://tailscale.com/kb/1218/nextdns/).
# "abc123" is example NextDNS ID, replace with yours.

View File

@@ -15,7 +15,7 @@ services:
- "3008:8080" # Headscale API端口
- "9090:9090" # Metrics监控端口
- "3478:3478" # STUN 端口
- "41641:41641" # DERP中继端口可选若Derper独立部署则无需映射
# - "41641:41641" # DERP中继端口可选若Derper独立部署则无需映射
- "12345:12345" # STUN 端口
- "8881:8881" # DERP 端口
- "50443:50443"
@@ -57,3 +57,4 @@ services:
# common314 5b6ed5947149bc2b6d203da688afa8d5969844af8151302e
# 9900k 734511957cbece2ae36622adf50a8ec6842d08fb771c771d
# 12600k-rocky-client 5b37e0d239b44f1ac514603d4f6f3629bc9c21aa0321e97d