re-add haproxy
This commit is contained in:
25
haproxy/avalanche-healthcheck.sh
Normal file
25
haproxy/avalanche-healthcheck.sh
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# $1 = Virtual Service IP (VIP)
|
||||||
|
# $2 = Virtual Service Port (VPT)
|
||||||
|
# $3 = Real Server IP (RIP)
|
||||||
|
# $4 = Real Server Port (RPT)
|
||||||
|
# $5 = Check Source IP
|
||||||
|
|
||||||
|
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
VIP=$1
|
||||||
|
VPT=$2
|
||||||
|
RIP=$3
|
||||||
|
RPT=$4
|
||||||
|
# RPT=8545
|
||||||
|
|
||||||
|
# Run curl with appropriate options
|
||||||
|
curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"eth_syncing","params": [],"id":1}' http://$RIP:$RPT/avalanche 2>/dev/null | jq '.result' -r | grep -q false
|
||||||
|
exit1=$?
|
||||||
|
|
||||||
|
peers=$(curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"net_peerCount","params": [],"id":1}' http://$RIP:$RPT/avalanche 2>/dev/null | jq '.result' -r)
|
||||||
|
|
||||||
|
# If any of the above tests failed, then exit 1.
|
||||||
|
if [[ "$exit1" -ne 0 ]]; then exit 1; fi
|
||||||
|
if [[ `printf "%d" $peers` == "0" || `printf "%d" $peers` == "1" ]]; then exit 1; fi
|
||||||
|
exit 0
|
||||||
25
haproxy/erigon-healthcheck.sh
Normal file
25
haproxy/erigon-healthcheck.sh
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# $1 = Virtual Service IP (VIP)
|
||||||
|
# $2 = Virtual Service Port (VPT)
|
||||||
|
# $3 = Real Server IP (RIP)
|
||||||
|
# $4 = Real Server Port (RPT)
|
||||||
|
# $5 = Check Source IP
|
||||||
|
|
||||||
|
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
VIP=$1
|
||||||
|
VPT=$2
|
||||||
|
RIP=$3
|
||||||
|
RPT=$4
|
||||||
|
# RPT=8545
|
||||||
|
|
||||||
|
# Run curl with appropriate options
|
||||||
|
curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"eth_syncing","params": [],"id":1}' http://$RIP:$RPT/erigon 2>/dev/null | jq '.result' -r | grep -q false
|
||||||
|
exit1=$?
|
||||||
|
|
||||||
|
peers=$(curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"net_peerCount","params": [],"id":1}' http://$RIP:$RPT/erigon 2>/dev/null | jq '.result' -r)
|
||||||
|
|
||||||
|
# If any of the above tests failed, then exit 1.
|
||||||
|
if [[ "$exit1" -ne 0 ]]; then exit 1; fi
|
||||||
|
if [[ `printf "%d" $peers` == "0" || `printf "%d" $peers` == "1" ]]; then exit 1; fi
|
||||||
|
exit 0
|
||||||
25
haproxy/geth-healthcheck.sh
Normal file
25
haproxy/geth-healthcheck.sh
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# $1 = Virtual Service IP (VIP)
|
||||||
|
# $2 = Virtual Service Port (VPT)
|
||||||
|
# $3 = Real Server IP (RIP)
|
||||||
|
# $4 = Real Server Port (RPT)
|
||||||
|
# $5 = Check Source IP
|
||||||
|
|
||||||
|
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
VIP=$1
|
||||||
|
VPT=$2
|
||||||
|
RIP=$3
|
||||||
|
RPT=$4
|
||||||
|
# RPT=8545
|
||||||
|
|
||||||
|
# Run curl with appropriate options
|
||||||
|
curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"eth_syncing","params": [],"id":1}' http://$RIP:$RPT/geth 2>/dev/null | jq '.result' -r | grep -q false
|
||||||
|
exit1=$?
|
||||||
|
|
||||||
|
peers=$(curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"net_peerCount","params": [],"id":1}' http://$RIP:$RPT/geth 2>/dev/null | jq '.result' -r)
|
||||||
|
|
||||||
|
# If any of the above tests failed, then exit 1.
|
||||||
|
if [[ "$exit1" -ne 0 ]]; then exit 1; fi
|
||||||
|
if [[ `printf "%d" $peers` == "0" || `printf "%d" $peers` == "1" ]]; then exit 1; fi
|
||||||
|
exit 0
|
||||||
25
haproxy/goerli-healthcheck.sh
Normal file
25
haproxy/goerli-healthcheck.sh
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# $1 = Virtual Service IP (VIP)
|
||||||
|
# $2 = Virtual Service Port (VPT)
|
||||||
|
# $3 = Real Server IP (RIP)
|
||||||
|
# $4 = Real Server Port (RPT)
|
||||||
|
# $5 = Check Source IP
|
||||||
|
|
||||||
|
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
VIP=$1
|
||||||
|
VPT=$2
|
||||||
|
RIP=$3
|
||||||
|
RPT=$4
|
||||||
|
# RPT=8545
|
||||||
|
|
||||||
|
# Run curl with appropriate options
|
||||||
|
curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"eth_syncing","params": [],"id":1}' http://$RIP:$RPT/goerli 2>/dev/null | jq '.result' -r | grep -q false
|
||||||
|
exit1=$?
|
||||||
|
|
||||||
|
peers=$(curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"net_peerCount","params": [],"id":1}' http://$RIP:$RPT/goerli 2>/dev/null | jq '.result' -r)
|
||||||
|
|
||||||
|
# If any of the above tests failed, then exit 1.
|
||||||
|
if [[ "$exit1" -ne 0 ]]; then exit 1; fi
|
||||||
|
if [[ `printf "%d" $peers` == "0" || `printf "%d" $peers` == "1" ]]; then exit 1; fi
|
||||||
|
exit 0
|
||||||
129
haproxy/haproxy.cfg
Normal file
129
haproxy/haproxy.cfg
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
global
|
||||||
|
|
||||||
|
nbproc 1
|
||||||
|
nbthread 2
|
||||||
|
cpu-map auto:1/1-2 0-1
|
||||||
|
|
||||||
|
log /dev/log local0
|
||||||
|
log /dev/log local1 notice
|
||||||
|
#chroot /var/lib/haproxy
|
||||||
|
user haproxy
|
||||||
|
group haproxy
|
||||||
|
daemon
|
||||||
|
external-check
|
||||||
|
|
||||||
|
defaults
|
||||||
|
mode http
|
||||||
|
log global
|
||||||
|
option httplog
|
||||||
|
option http-keep-alive
|
||||||
|
option dontlognull
|
||||||
|
option redispatch
|
||||||
|
option contstats
|
||||||
|
retries 3
|
||||||
|
backlog 10000
|
||||||
|
timeout client 50s
|
||||||
|
timeout connect 5s
|
||||||
|
timeout server 50s
|
||||||
|
timeout tunnel 3600s
|
||||||
|
timeout http-keep-alive 2s
|
||||||
|
timeout http-request 15s
|
||||||
|
timeout queue 30s
|
||||||
|
timeout tarpit 60s
|
||||||
|
default-server inter 3s rise 2 fall 3
|
||||||
|
option forwardfor
|
||||||
|
|
||||||
|
|
||||||
|
listen stats
|
||||||
|
bind *:9600
|
||||||
|
stats enable
|
||||||
|
stats uri /stats
|
||||||
|
stats realm Haproxy\ Statistics
|
||||||
|
stats auth pocket:P@ssw0rd00!
|
||||||
|
|
||||||
|
|
||||||
|
frontend rpc-frontend
|
||||||
|
bind *:80
|
||||||
|
acl host_is_erigon path_beg /erigon
|
||||||
|
acl host_is_goerli path_beg /goerli
|
||||||
|
acl host_is_avalanche path_beg /avalanche
|
||||||
|
acl host_is_ropsten path_beg /ropsten
|
||||||
|
acl host_is_geth path_beg /geth
|
||||||
|
acl host_is_rinkeby path_beg /rinkeby
|
||||||
|
|
||||||
|
use_backend erigon if host_is_erigon
|
||||||
|
use_backend goerli if host_is_goerli
|
||||||
|
use_backend avalanche if host_is_avalanche
|
||||||
|
use_backend ropsten if host_is_ropsten
|
||||||
|
use_backend geth if host_is_geth
|
||||||
|
use_backend rinkeby if host_is_rinkeby
|
||||||
|
|
||||||
|
default_backend backend-no-match
|
||||||
|
|
||||||
|
backend backend-no-match
|
||||||
|
http-request deny deny_status 400
|
||||||
|
|
||||||
|
backend erigon
|
||||||
|
mode http
|
||||||
|
balance roundrobin
|
||||||
|
|
||||||
|
option external-check
|
||||||
|
external-check path "/usr/bin:/bin"
|
||||||
|
external-check command /usr/local/etc/erigon-healthcheck.sh
|
||||||
|
|
||||||
|
server %[env(MAINNODE)] %[env(MAINNODE)]:80 check inter 10000 fall 3 rise 2 maxconn 2000
|
||||||
|
|
||||||
|
|
||||||
|
backend goerli
|
||||||
|
mode http
|
||||||
|
balance roundrobin
|
||||||
|
|
||||||
|
option external-check
|
||||||
|
external-check path "/usr/bin:/bin"
|
||||||
|
external-check command /usr/local/etc/goerli-healthcheck.sh
|
||||||
|
|
||||||
|
server %[env(MAINNODE)] %[env(MAINNODE)]:80 check inter 10000 fall 3 rise 2 maxconn 2000
|
||||||
|
|
||||||
|
|
||||||
|
backend rinkeby
|
||||||
|
mode http
|
||||||
|
balance roundrobin
|
||||||
|
|
||||||
|
option external-check
|
||||||
|
external-check path "/usr/bin:/bin"
|
||||||
|
external-check command /usr/local/etc/rinkeby-healthcheck.sh
|
||||||
|
|
||||||
|
server %[env(MAINNODE)] %[env(MAINNODE)]:80 check inter 10000 fall 3 rise 2 maxconn 2000
|
||||||
|
|
||||||
|
|
||||||
|
backend ropsten
|
||||||
|
mode http
|
||||||
|
balance roundrobin
|
||||||
|
|
||||||
|
option external-check
|
||||||
|
external-check path "/usr/bin:/bin"
|
||||||
|
external-check command /usr/local/etc/ropsten-healthcheck.sh
|
||||||
|
|
||||||
|
server %[env(MAINNODE)] %[env(MAINNODE)]:80 check inter 10000 fall 3 rise 2 maxconn 2000
|
||||||
|
|
||||||
|
|
||||||
|
backend avalanche
|
||||||
|
mode http
|
||||||
|
balance roundrobin
|
||||||
|
|
||||||
|
option external-check
|
||||||
|
external-check path "/usr/bin:/bin"
|
||||||
|
external-check command /usr/local/etc/avalanche-healthcheck.sh
|
||||||
|
|
||||||
|
server %[env(MAINNODE)] %[env(MAINNODE)]:80 check inter 10000 fall 3 rise 2 maxconn 2000
|
||||||
|
|
||||||
|
|
||||||
|
backend geth
|
||||||
|
mode http
|
||||||
|
balance roundrobin
|
||||||
|
|
||||||
|
option external-check
|
||||||
|
external-check path "/usr/bin:/bin"
|
||||||
|
external-check command /usr/local/etc/geth-healthcheck.sh
|
||||||
|
|
||||||
|
server %[env(MAINNODE)] %[env(MAINNODE)]:80 check inter 10000 fall 3 rise 2 maxconn 2000
|
||||||
25
haproxy/rinkeby-healthcheck.sh
Normal file
25
haproxy/rinkeby-healthcheck.sh
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# $1 = Virtual Service IP (VIP)
|
||||||
|
# $2 = Virtual Service Port (VPT)
|
||||||
|
# $3 = Real Server IP (RIP)
|
||||||
|
# $4 = Real Server Port (RPT)
|
||||||
|
# $5 = Check Source IP
|
||||||
|
|
||||||
|
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
VIP=$1
|
||||||
|
VPT=$2
|
||||||
|
RIP=$3
|
||||||
|
RPT=$4
|
||||||
|
# RPT=8545
|
||||||
|
|
||||||
|
# Run curl with appropriate options
|
||||||
|
curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"eth_syncing","params": [],"id":1}' http://$RIP:$RPT/rinkeby 2>/dev/null | jq '.result' -r | grep -q false
|
||||||
|
exit1=$?
|
||||||
|
|
||||||
|
peers=$(curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"net_peerCount","params": [],"id":1}' http://$RIP:$RPT/rinkeby 2>/dev/null | jq '.result' -r)
|
||||||
|
|
||||||
|
# If any of the above tests failed, then exit 1.
|
||||||
|
if [[ "$exit1" -ne 0 ]]; then exit 1; fi
|
||||||
|
if [[ `printf "%d" $peers` == "0" || `printf "%d" $peers` == "1" ]]; then exit 1; fi
|
||||||
|
exit 0
|
||||||
26
haproxy/ropsten-healthcheck.sh
Normal file
26
haproxy/ropsten-healthcheck.sh
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# $1 = Virtual Service IP (VIP)
|
||||||
|
# $2 = Virtual Service Port (VPT)
|
||||||
|
# $3 = Real Server IP (RIP)
|
||||||
|
# $4 = Real Server Port (RPT)
|
||||||
|
# $5 = Check Source IP
|
||||||
|
|
||||||
|
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
VIP=$1
|
||||||
|
VPT=$2
|
||||||
|
RIP=$3
|
||||||
|
RPT=$4
|
||||||
|
# RPT=8545
|
||||||
|
|
||||||
|
# Run curl with appropriate options
|
||||||
|
curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"eth_syncing","params": [],"id":1}' http://$RIP:$RPT/ropsten 2>/dev/null | jq '.result' -r | grep -q false
|
||||||
|
exit1=$?
|
||||||
|
|
||||||
|
peers=$(curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"net_peerCount","params": [],"id":1}' http://$RIP:$RPT/ropsten 2>/dev/null | jq '.result' -r)
|
||||||
|
|
||||||
|
# If any of the above tests failed, then exit 1.
|
||||||
|
if [[ "$exit1" -ne 0 ]]; then exit 1; fi
|
||||||
|
if [[ `printf "%d" $peers` == "0" || `printf "%d" $peers` == "1" ]]; then exit 1; fi
|
||||||
|
exit 0
|
||||||
15
docker-compose.haproxy.yml
Normal file
15
docker-compose.haproxy.yml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
version: '3.1'
|
||||||
|
|
||||||
|
services:
|
||||||
|
haproxy:
|
||||||
|
image: haproxytech/haproxy-alpine:latest
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
expose:
|
||||||
|
- 80
|
||||||
|
environment:
|
||||||
|
- AUTH_HTTP=$AUTH_HTTP
|
||||||
|
- MAINNODE=$MAIN_NODE
|
||||||
|
volumes:
|
||||||
|
- ./haproxy/:/usr/local/etc/haproxy:ro
|
||||||
|
restart: unless-stopped
|
||||||
Reference in New Issue
Block a user