0x00 配置

镜像只支持ARM和AMD64,其它架构需要支持请留言即可

# 创建文件夹和配置文件
mkdir -p ~/tuic  ~/tuic/cert && cd ~/tuic && touch docker-compose.yml tuic.json
# 编辑docker-compose.yml配置
nano docker-compose.yml

证书用acme.sh安装到~/tuic/cert文件夹中即可

docker-compose.yml

version: '3.9'
services:
  tuic:
    container_name: tuic
    image: altriabot/tuic
    restart: always
    network_mode: "host"
    volumes:
      - ./tuic.json:/etc/tuic/tuic.json
      - ./cert:/etc/tuic/cert

0x01 示例tuic.json

编辑tuic配置文件nano tuic.json

{
  "server": "[::]:443",
  "users": {
    "00000000-0000-0000-0000-000000000000": "PASSWORD"
  },
  "certificate": "/etc/tuic/cert/fullchain.crt",
  "private_key": "/etc/tuic/cert/private.key",
  "congestion_control": "bbr",
  "alpn": ["h3", "spdy/3.1"],
  "udp_relay_ipv6": true,
  "zero_rtt_handshake": false,
  "dual_stack": true,
  "auth_timeout": "6s",
  "task_negotiation_timeout": "3s",
  "max_idle_time": "60s",
  "max_external_packet_size": 1500,
  "send_window": 16777216,
  "receive_window": 8388608,
  "gc_interval": "3s",
  "gc_lifetime": "15s",
  "log_level": "warn"
}

0x02 启动tuic

# 启动tuic
docker-compose up -d

# 查看log
docker-compose log

# 实时查看log
docker-compose log -f

0x03 证书锁定

openssl x509 -noout -fingerprint -sha256 -inform pem -in ~/tuic/cert/fullchain.crt 
# 如下输出:
SHA256 
Fingerprint=9A:5C:E2:A1:08:B7:CE:FB:C4:E1:9A:F3:6E:27:79:65:BC:6F:2E:CD:6B:F3:62:D4:16:68:DF:95:ED:EB:F3:7A

0x04Surge中使用

TUIC V5 = tuic, 你的IP , 443, skip-cert-verify=true, sni=yourdomain.com, uuid=00000000-0000-0000-0000-000000000000, alpn=h3, password=PASSWORD, version=5, server-cert-fingerprint-sha256=9A:5C:E2:A1:08:B7:CE:FB:C4:E1:9A:F3:6E:27:79:65:BC:6F:2E:CD:6B:F3:62:D4:16:68:DF:95:ED:EB:F3:7A

0x05 log高级用法

通过docker-compose log -f查看log,在终端不是很好翻,通过以下配置,追加 environment: -log=1,开启log文件写入/etc/tuic/log/tuic.log,然后映射出来,通过tail log/tuic.log查看,或者下载log查看

version: "3.9"
services:
  tuic:
    container_name: tuic
    image: altriabot/tuic
    restart: always
    network_mode: "host"
    environment:
      - log=1
    volumes:
      - ./tuic.json:/etc/tuic/tuic.json
      - ./cert:/etc/tuic/cert
      - ./log:/etc/tuic/log

  • ~/tuic文件的目录结构大抵是这样的
.
├── cert
│   ├── fullchain.crt
│   └── private.key
├── docker-compose.yml
├── log
│   └── tuic.log
└── tuic.json

0x06 致谢