/ 技术 / 74浏览

docker搭建hysteria2

配置

docker-compose.yaml

version: "3.8" 
services:
  hysteria:
    image: tobyxdd/hysteria
    container_name: hy2
    restart: always
    network_mode: host
    volumes:
      - .:/etc/hysteria
    command: ["server", "-c", "/etc/hysteria/hysteria.yaml"]

hysteria.yaml

listen: :60000
tls:
  cert: /etc/hysteria/cert.crt    # 记住这个证书的名字
  key: /etc/hysteria/private.key  # 记住这个证书的名字
quic:
  initStreamReceiveWindow: 26843545
  maxStreamReceiveWindow: 26843545
  initConnReceiveWindow: 67108864
  maxConnReceiveWindow: 67108864
  maxIdleTimeout: 30s
  maxIncomingStreams: 1024
  disablePathMTUDiscovery: false
bandwidth:
  up: 300 mbps       # 可以改
  down: 100 mbps       # 可以改

ignoreClientBandwidth: false
udpIdleTimeout: 60s
auth:
  type: password
  password: 123456         # 改成你的密码

其中证书可以在 https://www.ssleye.com/ssltool/self_sign.html 生成自签证书。

运行

docker-compose up -d
docker logs hysteria # 查看日志是否运行成功

端口跳跃

# IPv4
iptables -t nat -A PREROUTING -i eth0 -p udp --dport 20000:50000 -j REDIRECT --to-ports 443

# IPv6
ip6tables -t nat -A PREROUTING -i eth0 -p udp --dport 20000:50000 -j REDIRECT --to-ports 443

1

  1. google

    good

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注