Shadowsocks HAProxy

Alpine Linux 镜像

sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories

假设 123456 是密码,1.2.3.4 和 2.3.4.5 分别是两台 Shadowsocks 服务器:

version: '3.7'
services:
  tencent:
    image: mritd/shadowsocks
    environment:
      - SS_MODULE=ss-local
      - 'SS_CONFIG=-s 127.0.0.1 -p 8388 -b 0.0.0.0 -l 1080 -m rc4-md5 -k 123456'
      - KCP_MODULE=kcpclient
      - 'KCP_CONFIG=-r 1.2.3.4:4000 -l :8388 -mode fast2'
      - KCP_FLAG=true
    command: /bin/sh
  alicloud:
    image: mritd/shadowsocks
    environment:
      - SS_MODULE=ss-local
      - 'SS_CONFIG=-s 127.0.0.1 -p 8388 -b 0.0.0.0 -l 1080 -m rc4-md5 -k 123456'
      - KCP_MODULE=kcpclient
      - 'KCP_CONFIG=-r 2.3.4.5:4000 -l :8388 -mode fast2'
      - KCP_FLAG=true
  haproxy:
    image: shadowsocks-haproxy
    ports:
      - 8388:8388
      - 80:80
    volumes:
      - ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg
      - ./ss-check:/usr/local/bin/ss-check
global
  external-check

defaults
  timeout connect 5000
  timeout client 50000
  timeout server 50000

frontend ss-server
  bind *:8388
  default_backend hongkong

backend hongkong
  option external-check
  external-check command /usr/local/bin/ss-check
  server tencent tencent:8388 check
  server alicloud alicloud:8388 check backup

listen stats
  mode http
  bind *:80
  stats enable
  stats uri /