Limour

Limour

临床医学在读。

【记录】GOST 进行 SOCKS5 的负载均衡

准备工作#

sudo docker network create cswitch
sudo docker run --rm --net=cswitch alpine/curl --socks5-hostname hysteria01:1580 https://myip.ipip.net
sudo docker run --rm --net=cswitch alpine/curl --socks5-hostname hysteria02:1580 https://myip.ipip.net

负载均衡#

mkdir -p ~/app/gost && cd ~/app/gost && nano docker-compose.yml
sudo docker-compose up -d && sudo docker-compose logs
sudo docker run --rm --net=cswitch alpine/curl --socks5-hostname gost:8580 https://myip.ipip.net
version: '3.3'
services:
  gost:
    restart: unless-stopped
    ports:
      - '8580:8580'
    image: ginuerzh/gost
    command: -L=:8580 -F=socks5://localhost:1580?ip=hysteria01:1580,hysteria02:1580
  
networks:
  default:
    external: true
    name: cswitch

健康检查#

nano Health_check.sh
# chmod +x Health_check.sh 
# dos2unix Health_check.sh 
/home/limour/app/hysteria01/Health_check.sh
#!/bin/bash

COMPOSE_FILE=/home/limour/app/hysteria01/docker-compose.yml

while true; do
    output=$(sudo docker run --rm --net=cswitch alpine/curl -fs --socks5-hostname hysteria01:1580 https://www.google.com/robots.txt)
    if [ $? -eq 0 ]; then
        echo "Health check successful"
    else
        echo "Health check failed"
        sudo docker-compose -f $COMPOSE_FILE restart
    fi
    sleep 300
done

定时检查#

nano Health_check.sh
# chmod +x Health_check.sh 
# dos2unix Health_check.sh 
/home/limour/app/hysteria01/Health_check.sh
crontab -e
* * * * * /usr/bin/sudo /home/limour/app/hysteria01/Health_check.sh
* * * * * /usr/bin/sudo /home/limour/app/hysteria02/Health_check.sh
crontab -l
# sudo dpkg-reconfigure postfix
tail /var/spool/mail/limour
#!/bin/bash

COMPOSE_FILE=/home/limour/app/hysteria02/docker-compose.yml

output=$(sudo docker run --rm --net=cswitch alpine/curl -fs --socks5-hostname hysteria02:1580 https://www.google.com/robots.txt)
if [ $? -eq 0 ]; then
	echo "Health check successful"
else
	echo "Health check failed"
	sudo docker-compose -f $COMPOSE_FILE restart
fi
加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。