-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
87 lines (62 loc) · 1.9 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
SHELL=/usr/bin/env bash
ifndef GIT_ORG
GIT_ORG=0LNetworkCommunity
endif
ifndef GIT_REPO
GIT_REPO=rpc-load-balancer
endif
ifndef REPO_PATH
REPO_PATH=~/${GIT_REPO}
endif
ifndef RPC_LB_DOMAIN
RPC_LB_DOMAIN=rpc.openlibra.space
endif
ifndef RPC_LB_SITE_FILE
RPC_LB_SITE_FILE=rpc-load-balancer
endif
define RPC_LB_SITE_CONTENTS
upstream fullnodes {
server 127.0.0.1:8080;
}
server {
listen 80;
server_name ${RPC_LB_DOMAIN};
return 301 https://$$host$$request_uri;
}
server {
listen 8080 ssl;
server_name ${RPC_LB_DOMAIN};
ssl_certificate /etc/letsencrypt/live/${RPC_LB_DOMAIN}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/${RPC_LB_DOMAIN}/privkey.pem;
location / {
proxy_pass http://fullnodes;
proxy_set_header Host $$host;
proxy_set_header X-Real-IP $$remote_addr;
proxy_set_header X-Forwarded-For $$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $$scheme;
}
}
endef
export RPC_LB_SITE_CONTENTS
install: rpc-load-balancer
sudo apt install -y python3 nginx nginx-common nginx-full
sudo ln -sf /etc/nginx/sites-available/${RPC_LB_SITE_FILE} /etc/nginx/sites-enabled/${RPC_LB_SITE_FILE}
-sudo systemctl reload nginx
sudo apt install certbot python3-certbot-nginx -y
sudo certbot certonly --manual --preferred-challenges=dns --server https://acme-v02.api.letsencrypt.org/directory --domain ${RPC_LB_DOMAIN}
sudo systemctl reload nginx
pull:
cd ${REPO_PATH} && git pull
push:
cd ${REPO_PATH} && git add -A && git commit -m "rpc health check" && git push
update:
cd ${REPO_PATH} && sudo python3 update_endpoints.py /etc/nginx/sites-available/${RPC_LB_SITE_FILE} > ${REPO_PATH}/update.log 2>&1
sudo nginx -t
sudo systemctl reload nginx
cron: pull update push
echo "Finished!"
cron-nogit: update
echo "Finished without git!"
rpc-load-balancer:
mkdir -p /etc/nginx/sites-available/
@echo "$$RPC_LB_SITE_CONTENTS" | sudo tee /etc/nginx/sites-available/${RPC_LB_SITE_FILE}