Skip to content

Commit d654f2e

Browse files
committed
nginx config scripts update
1 parent a6a64ea commit d654f2e

7 files changed

+97
-23
lines changed

nginx/bonus.SSL_for_RTL.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,27 @@
22
# To download and run:
33
# $ wget https://github.com/openoms/bitcoin-tutorials/raw/master/nginx/bonus.SSL_for_RTL.sh && bash bonus.SSL_for_RTL.sh
44

5-
65
# For the certificate to be obtained successfully a dynamic DNS and port forwarding is needed
76
# Need to forward port 80 to the IP of your RaspiBlitz for certbot
87
# Forward port 3002 to be able to access RTL from outside of your LAN
98

109
# https://www.raspberrypi.org/documentation/remote-access/web-server/nginx.md
1110

11+
# check for certbot and nginx
12+
if dpkg -l | grep -qw "certbot"; then
13+
echo "# certbot is already installed"
14+
else
15+
sudo apt install -y certbot
16+
fi
17+
if dpkg -l | grep -qw "nginx"; then
18+
echo "# nginx is already installed"
19+
else
20+
sudo apt install -y nginx
21+
fi
22+
1223
echo ""
1324
echo "***"
14-
echo "Please confirm that the port 80 is forwarded to the IP of the RaspiBlitz by pressing [ENTER]"
25+
echo "Please confirm that the port 80 is forwarded to the IP of the RaspiBlitz by pressing [ENTER]"
1526
read key
1627

1728
echo ""
@@ -74,7 +85,6 @@ RestartSec=60
7485

7586
sudo systemctl enable certbot.timer
7687

77-
7888
echo "Setting up nginx.conf"
7989
echo "***"
8090
echo ""
@@ -88,7 +98,7 @@ elif [ ${isRTL} -eq 0 ]; then
8898
isStream=$(sudo cat /etc/nginx/nginx.conf 2>/dev/null | grep -c 'stream {')
8999
if [ ${isStream} -eq 0 ]; then
90100

91-
echo "
101+
echo "
92102
stream {
93103
upstream RTL {
94104
server 127.0.0.1:3000;

nginx/btcpayserver_subdomain.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
# WORK IN PROGRESS
44
# see https://gist.github.com/NicolasDorier/1a7fce6836ee55a7fa2c7f65417b88b5
55

6+
# check for certbot and nginx
7+
if dpkg -l | grep -qw "certbot"; then
8+
echo "# certbot is already installed"
9+
else
10+
sudo apt install -y certbot
11+
fi
12+
if dpkg -l | grep -qw "nginx"; then
13+
echo "# nginx is already installed"
14+
else
15+
sudo apt install -y nginx
16+
fi
17+
618
echo "
719
Input your email:
820
"

nginx/custom_website_subdomain.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
#!/bin/bash
22

3+
# check for certbot and nginx
4+
if dpkg -l | grep -qw "certbot"; then
5+
echo "# certbot is already installed"
6+
else
7+
sudo apt install -y certbot
8+
fi
9+
if dpkg -l | grep -qw "nginx"; then
10+
echo "# nginx is already installed"
11+
else
12+
sudo apt install -y nginx
13+
fi
14+
315
echo "
416
Input your email:
517
"

nginx/electrum_server_subdomain.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
#!/bin/bash
22

3+
# check for certbot and nginx
4+
if dpkg -l | grep -qw "certbot"; then
5+
echo "# certbot is already installed"
6+
else
7+
sudo apt install -y certbot
8+
fi
9+
if dpkg -l | grep -qw "nginx"; then
10+
echo "# nginx is already installed"
11+
else
12+
sudo apt install -y nginx
13+
fi
14+
315
echo "
416
Input your email:
517
"

nginx/https_redirect_to_subdomain.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
#!/bin/bash
22

3+
# check for certbot and nginx
4+
if dpkg -l | grep -qw "certbot"; then
5+
echo "# certbot is already installed"
6+
else
7+
sudo apt install -y certbot
8+
fi
9+
if dpkg -l | grep -qw "nginx"; then
10+
echo "# nginx is already installed"
11+
else
12+
sudo apt install -y nginx
13+
fi
14+
315
echo "
416
Input your email:
517
"

nginx/mempool_subdomain.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
#!/bin/bash
22

3+
# check for certbot and nginx
4+
if dpkg -l | grep -qw "certbot"; then
5+
echo "# certbot is already installed"
6+
else
7+
sudo apt install -y certbot
8+
fi
9+
if dpkg -l | grep -qw "nginx"; then
10+
echo "# nginx is already installed"
11+
else
12+
sudo apt install -y nginx
13+
fi
14+
315
echo "
416
Input your email:"
517
read EMAIL

nginx/nostr-relay.sh

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
#!/bin/bash
22

3+
# check for certbot and nginx
4+
if dpkg -l | grep -qw "certbot"; then
5+
echo "# certbot is already installed"
6+
else
7+
sudo apt install -y certbot
8+
fi
9+
if dpkg -l | grep -qw "nginx"; then
10+
echo "# nginx is already installed"
11+
else
12+
sudo apt install -y nginx
13+
fi
14+
315
echo "
416
Input your email:
517
"
@@ -24,8 +36,8 @@ eg.: /nostrrelay/nNZ59JFH
2436
read RELAY
2537

2638
sudo certbot certonly -a standalone -m $EMAIL --agree-tos \
27-
-d $SUBDOMAIN --expand -n --pre-hook "service nginx stop" \
28-
--post-hook "service nginx start" || exit 1
39+
-d $SUBDOMAIN --expand -n --pre-hook "service nginx stop" \
40+
--post-hook "service nginx start" || exit 1
2941

3042
# copy in place on a remote machine if needed
3143
#sudo cat /etc/letsencrypt/live/$SUBDOMAIN/fullchain.pem
@@ -51,29 +63,21 @@ server {
5163
ssl_trusted_certificate /etc/letsencrypt/live/$SUBDOMAIN/chain.pem;
5264
5365
location / {
54-
proxy_pass https://${SUBDOMAIN}${RELAY};
55-
# to allow wss:// connections
66+
proxy_pass ${SERVER}${RELAY};
67+
68+
# WebSocket support
5669
proxy_http_version 1.1;
57-
proxy_set_header Upgrade \$http_upgrade;
58-
proxy_set_header Connection \"upgrade\";
70+
proxy_set_header Upgrade \$http_upgrade; # Upgrade header for WebSocket
71+
proxy_set_header Connection \"upgrade\"; # Connection header for WebSocket
5972
60-
# from https://github.com/rootzoll/raspiblitz/blob/v1.7/home.admin/assets/nginx/snippets/ssl-proxy-params.conf
61-
proxy_SERVER off;
62-
proxy_set_header Host \$http_host;
73+
# Additional headers
74+
proxy_set_header Host \$host;
6375
proxy_set_header X-Real-IP \$remote_addr;
6476
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
6577
proxy_set_header X-Forwarded-Proto https;
66-
}
6778
68-
location $RELAY {
69-
proxy_pass $SERVER;
70-
proxy_http_version 1.1;
71-
proxy_set_header Upgrade \$http_upgrade;
72-
proxy_set_header Connection \"upgrade\";
73-
proxy_set_header Host \$host;
74-
proxy_set_header X-Real-IP \$remote_addr;
75-
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
76-
proxy_set_header X-Forwarded-Proto \$scheme;
79+
# Disable proxy redirects
80+
proxy_redirect off;
7781
}
7882
}" | sudo tee /etc/nginx/sites-available/$SUBDOMAIN
7983

0 commit comments

Comments
 (0)