Skip to content

Commit 87557f6

Browse files
DeviaVirnitramiz
authored andcommitted
Set real IP from GLB
1 parent 9067d8b commit 87557f6

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

contrib/nginx.conf.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Set the IP ranges of your Google Cloud Load Balancer
2+
set_real_ip_from 130.211.0.0/22;
3+
set_real_ip_from 35.191.0.0/16;
4+
5+
# Use the IP address in the X-Forwarded-For header as the client IP
6+
real_ip_header X-Forwarded-For;
7+
real_ip_recursive on;
8+
19
geo $limit {
210
default 1;
311
34.70.28.228/32 0;

run.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ MODE=$2
77

88
SYNC_SECRET=$4
99
SYNC_SOURCE=$5
10+
NGINX_GCLB_IP=${NGINX_GCLB_IP:-35.201.74.156} # bs.info
1011

1112
if [ -z "$FLAVOR" ] || [ ! -d /srv/explorer/static/$FLAVOR ]; then
1213
echo "Please provide bitcoin-mainnet, bitcoin-testnet, bitcoin-signet, bitcoin-regtest, liquid-mainnet, liquid-testnet or liquid-regtest as a parameter"
@@ -221,6 +222,11 @@ fi
221222
preprocess /srv/explorer/source/contrib/nginx.conf.in /etc/nginx/sites-enabled/default
222223
sed -i 's/user www-data;/user root;/' /etc/nginx/nginx.conf
223224

225+
# Set real IP of service
226+
if [ -n "NGINX_GCLB_IP" ]; then
227+
sed -i "/set_real_ip_from 35.191.0.0\/16;/a set_real_ip_from ${NGINX_GCLB_IP}\/32; # GCLB public IP" /etc/nginx/sites-enabled/default
228+
fi
229+
224230
# Make mempool contents available over nginx, protected with SYNC_SECRET
225231
if [ -n "$SYNC_SECRET" ]; then
226232
echo "sync:{PLAIN}$SYNC_SECRET" > /srv/explorer/htpasswd

0 commit comments

Comments
 (0)