Limour

Limour

临床医学在读。

[Record] GOST performs load balancing for SOCKS5.

Preparation#

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

Load Balancing#

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

Health Check#

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

Scheduled Check#

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
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.