nginx config scripts update

This commit is contained in:
openoms
2024-08-29 16:10:31 +02:00
parent a6a64ea590
commit d654f2e88e
7 changed files with 98 additions and 24 deletions

View File

@@ -2,16 +2,27 @@
# To download and run: # To download and run:
# $ wget https://github.com/openoms/bitcoin-tutorials/raw/master/nginx/bonus.SSL_for_RTL.sh && bash bonus.SSL_for_RTL.sh # $ wget https://github.com/openoms/bitcoin-tutorials/raw/master/nginx/bonus.SSL_for_RTL.sh && bash bonus.SSL_for_RTL.sh
# For the certificate to be obtained successfully a dynamic DNS and port forwarding is needed # For the certificate to be obtained successfully a dynamic DNS and port forwarding is needed
# Need to forward port 80 to the IP of your RaspiBlitz for certbot # Need to forward port 80 to the IP of your RaspiBlitz for certbot
# Forward port 3002 to be able to access RTL from outside of your LAN # Forward port 3002 to be able to access RTL from outside of your LAN
# https://www.raspberrypi.org/documentation/remote-access/web-server/nginx.md # https://www.raspberrypi.org/documentation/remote-access/web-server/nginx.md
# check for certbot and nginx
if dpkg -l | grep -qw "certbot"; then
echo "# certbot is already installed"
else
sudo apt install -y certbot
fi
if dpkg -l | grep -qw "nginx"; then
echo "# nginx is already installed"
else
sudo apt install -y nginx
fi
echo "" echo ""
echo "***" echo "***"
echo "Please confirm that the port 80 is forwarded to the IP of the RaspiBlitz by pressing [ENTER]" echo "Please confirm that the port 80 is forwarded to the IP of the RaspiBlitz by pressing [ENTER]"
read key read key
echo "" echo ""
@@ -74,7 +85,6 @@ RestartSec=60
sudo systemctl enable certbot.timer sudo systemctl enable certbot.timer
echo "Setting up nginx.conf" echo "Setting up nginx.conf"
echo "***" echo "***"
echo "" echo ""
@@ -88,7 +98,7 @@ elif [ ${isRTL} -eq 0 ]; then
isStream=$(sudo cat /etc/nginx/nginx.conf 2>/dev/null | grep -c 'stream {') isStream=$(sudo cat /etc/nginx/nginx.conf 2>/dev/null | grep -c 'stream {')
if [ ${isStream} -eq 0 ]; then if [ ${isStream} -eq 0 ]; then
echo " echo "
stream { stream {
upstream RTL { upstream RTL {
server 127.0.0.1:3000; server 127.0.0.1:3000;

View File

@@ -3,6 +3,18 @@
# WORK IN PROGRESS # WORK IN PROGRESS
# see https://gist.github.com/NicolasDorier/1a7fce6836ee55a7fa2c7f65417b88b5 # see https://gist.github.com/NicolasDorier/1a7fce6836ee55a7fa2c7f65417b88b5
# check for certbot and nginx
if dpkg -l | grep -qw "certbot"; then
echo "# certbot is already installed"
else
sudo apt install -y certbot
fi
if dpkg -l | grep -qw "nginx"; then
echo "# nginx is already installed"
else
sudo apt install -y nginx
fi
echo " echo "
Input your email: Input your email:
" "

View File

@@ -1,5 +1,17 @@
#!/bin/bash #!/bin/bash
# check for certbot and nginx
if dpkg -l | grep -qw "certbot"; then
echo "# certbot is already installed"
else
sudo apt install -y certbot
fi
if dpkg -l | grep -qw "nginx"; then
echo "# nginx is already installed"
else
sudo apt install -y nginx
fi
echo " echo "
Input your email: Input your email:
" "

View File

@@ -1,5 +1,17 @@
#!/bin/bash #!/bin/bash
# check for certbot and nginx
if dpkg -l | grep -qw "certbot"; then
echo "# certbot is already installed"
else
sudo apt install -y certbot
fi
if dpkg -l | grep -qw "nginx"; then
echo "# nginx is already installed"
else
sudo apt install -y nginx
fi
echo " echo "
Input your email: Input your email:
" "

View File

@@ -1,5 +1,17 @@
#!/bin/bash #!/bin/bash
# check for certbot and nginx
if dpkg -l | grep -qw "certbot"; then
echo "# certbot is already installed"
else
sudo apt install -y certbot
fi
if dpkg -l | grep -qw "nginx"; then
echo "# nginx is already installed"
else
sudo apt install -y nginx
fi
echo " echo "
Input your email: Input your email:
" "

View File

@@ -1,5 +1,17 @@
#!/bin/bash #!/bin/bash
# check for certbot and nginx
if dpkg -l | grep -qw "certbot"; then
echo "# certbot is already installed"
else
sudo apt install -y certbot
fi
if dpkg -l | grep -qw "nginx"; then
echo "# nginx is already installed"
else
sudo apt install -y nginx
fi
echo " echo "
Input your email:" Input your email:"
read EMAIL read EMAIL

View File

@@ -1,5 +1,17 @@
#!/bin/bash #!/bin/bash
# check for certbot and nginx
if dpkg -l | grep -qw "certbot"; then
echo "# certbot is already installed"
else
sudo apt install -y certbot
fi
if dpkg -l | grep -qw "nginx"; then
echo "# nginx is already installed"
else
sudo apt install -y nginx
fi
echo " echo "
Input your email: Input your email:
" "
@@ -24,8 +36,8 @@ eg.: /nostrrelay/nNZ59JFH
read RELAY read RELAY
sudo certbot certonly -a standalone -m $EMAIL --agree-tos \ sudo certbot certonly -a standalone -m $EMAIL --agree-tos \
-d $SUBDOMAIN --expand -n --pre-hook "service nginx stop" \ -d $SUBDOMAIN --expand -n --pre-hook "service nginx stop" \
--post-hook "service nginx start" || exit 1 --post-hook "service nginx start" || exit 1
# copy in place on a remote machine if needed # copy in place on a remote machine if needed
#sudo cat /etc/letsencrypt/live/$SUBDOMAIN/fullchain.pem #sudo cat /etc/letsencrypt/live/$SUBDOMAIN/fullchain.pem
@@ -51,29 +63,21 @@ server {
ssl_trusted_certificate /etc/letsencrypt/live/$SUBDOMAIN/chain.pem; ssl_trusted_certificate /etc/letsencrypt/live/$SUBDOMAIN/chain.pem;
location / { location / {
proxy_pass https://${SUBDOMAIN}${RELAY}; proxy_pass ${SERVER}${RELAY};
# to allow wss:// connections
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection \"upgrade\";
# from https://github.com/rootzoll/raspiblitz/blob/v1.7/home.admin/assets/nginx/snippets/ssl-proxy-params.conf # WebSocket support
proxy_SERVER off;
proxy_set_header Host \$http_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 https;
}
location $RELAY {
proxy_pass $SERVER;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade; proxy_set_header Upgrade \$http_upgrade; # Upgrade header for WebSocket
proxy_set_header Connection \"upgrade\"; proxy_set_header Connection \"upgrade\"; # Connection header for WebSocket
# Additional headers
proxy_set_header Host \$host; proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr; proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme; proxy_set_header X-Forwarded-Proto https;
# Disable proxy redirects
proxy_redirect off;
} }
}" | sudo tee /etc/nginx/sites-available/$SUBDOMAIN }" | sudo tee /etc/nginx/sites-available/$SUBDOMAIN