启动示例

  • 新建docker-compose.yml
  • 其中volumes需要把自己的证书路径替换一下,这里我是直接使用caddy生成的证书
  • 其中my-net最好手动先创建,如果不使用docker network,记得修改Caddyfile,使用localhost或127.0.0.1的写法
version: '3'

networks:
  my-net:
    external: true

services:
  derper:
    image: ghcr.io/yangchuansheng/derper:latest
    container_name: derper
    restart: always
    network_mode: "my-net"
    ports:
      - "12345:12345"
      - "3478:3478/udp"
    volumes:
      - /usr/local/moac/caddy/data/caddy/certificates/acme-v02.api.letsencrypt.org-directory/example.com:/app/certs
      - /var/run/tailscale/tailscaled.sock:/var/run/tailscale/tailscaled.sock
    environment:
      DERP_CERT_MODE: "manual"
      DERP_ADDR: ":12345"
      DERP_DOMAIN: "example.com"
      DERP_VERIFY_CLIENTS: "true"

Caddyfile示例

注意替换自己的域名放通对应防火墙端口

example.com:12345 {
  reverse_proxy derper:12345
}

ACL示例

修改tailscale中的 Access Controls ,参数可以自己替换,另外注意替换域名

  "derpMap": {
    "OmitDefaultRegions": true, // 是否只连接自建 derper 节点
    "Regions": {
      "900": {
        "RegionID": 900,
        "RegionCode": "node_code",
        "Nodes": [
          {
            "Name": "node_name",
            "RegionID": 900,
            "HostName": "example.com", // 域名
            "STUNPort": 3478,
            "DERPPort": 12345,
          }
        ]
      }
    }
  }