跳至内容
haproxy 配置

haproxy 配置

mac 配置

global
    log /dev/log local0 debug
    log-tag haproxy
    external-check
    insecure-fork-wanted

defaults
    log global
    mode tcp
    timeout connect 30s
    timeout client 30s
    timeout server 30s

frontend socks5_in
    bind *:1080
    mode tcp
    option tcplog
    log global
    default_backend socks5_pool

frontend stats
  mode http
  bind :8404
  stats enable
  stats refresh 10s
  stats uri /stats
  stats show-modules

backend socks5_pool
    mode tcp
    #balance roundrobin
    balance leastconn
    option log-health-checks
    log global
    option external-check
    option allbackups
    timeout check 10s
    external-check command /xxx/xxx/xxx/check_socks5.sh
    server cloudflare_grpc 127.0.0.1:10850 check inter 5s fall 3 rise 2 
    server cloudflare_trojan 127.0.0.1:10821 check inter 5s fall 3 rise 2 
    server cloudflare_trojan_2 127.0.0.1:10822 check inter 5s fall 3 rise 2 
    server cloudflare_vmess 127.0.0.1:10811 check inter 5s fall 3 rise 2 
    server cloudflare_vmess_2 127.0.0.1:10812 check inter 5s fall 3 rise 2 
    server hysteria 127.0.0.1:10830 check inter 5s fall 3 rise 2 backup
    server vmess_kcp 127.0.0.1:10800 check inter 5s fall 3 rise 2 backup

linux 配置

global
    log /dev/log local0 debug
    log-tag haproxy
    external-check
    insecure-fork-wanted

defaults
    log global
    mode tcp
    timeout connect 30s
    timeout client 30s
    timeout server 30s

frontend socks5_in
    bind *:1080
    mode tcp
    option tcplog
    log global
    default_backend socks5_pool

frontend stats
  mode http
  bind :8404
  stats enable
  stats refresh 10s
  stats uri /stats
  stats show-modules

backend socks5_pool
    mode tcp
    #balance roundrobin
    balance leastconn
    option log-health-checks
    log global
    option external-check
    option allbackups
    timeout check 10s
    external-check command /xxx/xxx/check_socks5.sh
    server cloudflare_grpc 127.0.0.1:10850 check inter 5s fall 3 rise 2 
    server cloudflare_trojan 127.0.0.1:10821 check inter 5s fall 3 rise 2 
    server cloudflare_trojan_2 127.0.0.1:10822 check inter 5s fall 3 rise 2 
    server cloudflare_vmess 127.0.0.1:10811 check inter 5s fall 3 rise 2 
    server cloudflare_vmess_2 127.0.0.1:10812 check inter 5s fall 3 rise 2 
    server hysteria 127.0.0.1:10830 check inter 5s fall 3 rise 2 backup
    server vmess_kcp 127.0.0.1:10800 check inter 5s fall 3 rise 2 backup

check_socks5.sh

#!/bin/bash
/usr/bin/curl --max-time 5 --socks5-hostname $3:$4 https://www.google.com > /dev/null 2>&1
#code=$?
exit $?
最后更新于