mirror of
https://github.com/openoms/bitcoin-tutorials.git
synced 2025-12-19 12:54:19 +01:00
logic to fill nginx.conf
This commit is contained in:
@@ -122,20 +122,23 @@ echo "Setting up nginx.conf"
|
|||||||
echo "***"
|
echo "***"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo "If there is other an stream service is installed with Nginx already, you will need to edit the nginx.conf manually to remove the duplicate stream entry by running \`sudo nano /etc/nginx/nginx.conf\`."
|
isElectrs=$(sudo cat /etc/nginx/nginx.conf 2>/dev/null | grep -c 'upstream electrs')
|
||||||
echo "please press a key to continue"
|
if [ ${isElectrs} -gt 0 ]; then
|
||||||
read key
|
echo "electrs is already configured with Nginx. To edit manually run \`sudo nano /etc/nginx/nginx.conf\`"
|
||||||
|
|
||||||
echo "
|
elif [ ${isElectrs} -eq 0 ]; then
|
||||||
|
|
||||||
|
isStream=$(sudo cat /etc/nginx/nginx.conf 2>/dev/null | grep -c 'stream {')
|
||||||
|
if [ ${isStream} -eq 0 ]; then
|
||||||
|
|
||||||
|
echo "
|
||||||
stream {
|
stream {
|
||||||
upstream electrs {
|
upstream electrs {
|
||||||
server 127.0.0.1:50001;
|
server 127.0.0.1:50001;
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 50002 ssl;
|
listen 50002 ssl;
|
||||||
proxy_pass electrs;
|
proxy_pass electrs;
|
||||||
|
|
||||||
ssl_certificate /etc/letsencrypt/live/$YOUR_DOMAIN/fullchain.pem;
|
ssl_certificate /etc/letsencrypt/live/$YOUR_DOMAIN/fullchain.pem;
|
||||||
ssl_certificate_key /etc/letsencrypt/live/$YOUR_DOMAIN/privkey.pem;
|
ssl_certificate_key /etc/letsencrypt/live/$YOUR_DOMAIN/privkey.pem;
|
||||||
ssl_session_cache shared:SSL:1m;
|
ssl_session_cache shared:SSL:1m;
|
||||||
@@ -143,8 +146,33 @@ stream {
|
|||||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
||||||
ssl_prefer_server_ciphers on;
|
ssl_prefer_server_ciphers on;
|
||||||
}
|
}
|
||||||
}
|
}" | sudo tee -a /etc/nginx/nginx.conf
|
||||||
" | sudo tee -a /etc/nginx/nginx.conf
|
|
||||||
|
elif [ ${isStream} -eq 1 ]; then
|
||||||
|
sudo truncate -s-2 /etc/nginx/nginx.conf
|
||||||
|
echo "
|
||||||
|
|
||||||
|
upstream electrs {
|
||||||
|
server 127.0.0.1:50001;
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
listen 50002 ssl;
|
||||||
|
proxy_pass electrs;
|
||||||
|
ssl_certificate /etc/letsencrypt/live/$YOUR_DOMAIN/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/$YOUR_DOMAIN/privkey.pem;
|
||||||
|
ssl_session_cache shared:SSL:1m;
|
||||||
|
ssl_session_timeout 4h;
|
||||||
|
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
||||||
|
ssl_prefer_server_ciphers on;
|
||||||
|
}
|
||||||
|
}" | sudo tee -a /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
elif [ ${isStream} -gt 1 ]; then
|
||||||
|
|
||||||
|
echo " Too many \`stream\` commands in nginx.conf. Please edit manually: \`sudo nano /etc/nginx/nginx.conf\` and retry"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
echo "allow port 50002 on ufw"
|
echo "allow port 50002 on ufw"
|
||||||
sudo ufw allow 50002
|
sudo ufw allow 50002
|
||||||
@@ -152,8 +180,5 @@ sudo ufw allow 50002
|
|||||||
sudo systemctl enable nginx
|
sudo systemctl enable nginx
|
||||||
sudo systemctl restart nginx
|
sudo systemctl restart nginx
|
||||||
|
|
||||||
echo "If there is an error starting Nginx there is a stream service installed with Nginx already.
|
|
||||||
You will need to edit the nginx.conf manually to remove the duplicate stream entry by running \`sudo nano /etc/nginx/nginx.conf\` \
|
|
||||||
and restart nginx with \`sudo systemctl restart nginx\`."
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Set the \`Current Electrum server\` of you Eclair wallet to \`$YOUR_DOMAIN:50002\` and make sure the port 50002 is forwarded on your router"
|
echo "Set the \`Current Electrum server\` of you Eclair wallet to \`$YOUR_DOMAIN:50002\` and make sure the port 50002 is forwarded on your router"
|
||||||
|
|||||||
Reference in New Issue
Block a user