support ip address as new argument in addsub.sh

This commit is contained in:
fram3d 2024-01-27 22:37:26 +01:00
parent 935cfc0979
commit 9cc158336b
Signed by: fram3d
GPG Key ID: 938920E709EEA32A
3 changed files with 42 additions and 0 deletions

View File

@ -5,6 +5,7 @@ DMZKEYFILE=$(echo -n ~)"/.ssh/dmz"
NGINXHOST=$1 NGINXHOST=$1
SUBDOMAIN=$2 SUBDOMAIN=$2
CTIPADDRESS=$3
if [[ -z "$NGINXHOST" ]]; then if [[ -z "$NGINXHOST" ]]; then
echo "Set Nginx Host" echo "Set Nginx Host"
@ -16,10 +17,15 @@ if [[ -z "$SUBDOMAIN" ]]; then
exit 1 exit 1
fi fi
ssh-add -t 200 $DMZKEYFILE ssh-add -t 200 $DMZKEYFILE
torsocks scp ./remotecmd $NGINXHOST:/root/remotecmd.sh torsocks scp ./remotecmd $NGINXHOST:/root/remotecmd.sh
torsocks scp ./subdomain.dmz.rs.http $NGINXHOST:/etc/nginx/sites-available/ torsocks scp ./subdomain.dmz.rs.http $NGINXHOST:/etc/nginx/sites-available/
torsocks scp ./subdomain.dmz.rs.https $NGINXHOST:/etc/nginx/sites-available/ torsocks scp ./subdomain.dmz.rs.https $NGINXHOST:/etc/nginx/sites-available/
if [[ -z "$CTIPADDRESS" ]]; then
torsocks scp ./subdomain.dmz.rs.proxy $NGINXHOST:/etc/nginx/sites-available/
fi
torsocks ssh $NGINXHOST "chmod +x /root/remotecmd.sh; /root/remotecmd.sh $SUBDOMAIN" torsocks ssh $NGINXHOST "chmod +x /root/remotecmd.sh; /root/remotecmd.sh $SUBDOMAIN"

View File

@ -8,10 +8,17 @@ if [[ -z "$SUBDOMAIN" ]]; then
exit 1 exit 1
fi fi
if [[ -z "$CTIPADDRESS" ]]; then
sed -i 's/CTIPADDRESS/'$CTIPADDRESS'/g' /etc/nginx/sites-available/subdomain.dmz.rs.proxy
mv /etc/nginx/sites-available/subdomain.dmz.rs.proxy /etc/nginx/sites-available/subdomain.dmz.rs.https
fi
sed -i 's/subdomain/'$SUBDOMAIN'/g' /etc/nginx/sites-available/subdomain.dmz.rs.http sed -i 's/subdomain/'$SUBDOMAIN'/g' /etc/nginx/sites-available/subdomain.dmz.rs.http
sed -i 's/subdomain/'$SUBDOMAIN'/g' /etc/nginx/sites-available/subdomain.dmz.rs.https sed -i 's/subdomain/'$SUBDOMAIN'/g' /etc/nginx/sites-available/subdomain.dmz.rs.https
sed -i 's/subnodot/'$SUBNODOT'/g' /etc/nginx/sites-available/subdomain.dmz.rs.http sed -i 's/subnodot/'$SUBNODOT'/g' /etc/nginx/sites-available/subdomain.dmz.rs.http
sed -i 's/subnodot/'$SUBNODOT'/g' /etc/nginx/sites-available/subdomain.dmz.rs.https sed -i 's/subnodot/'$SUBNODOT'/g' /etc/nginx/sites-available/subdomain.dmz.rs.https
mkdir /var/www/"$SUBNODOT"dmzrs/ mkdir /var/www/"$SUBNODOT"dmzrs/
mv /etc/nginx/sites-available/subdomain.dmz.rs.http /etc/nginx/sites-available/"$SUBDOMAIN".dmz.rs.http mv /etc/nginx/sites-available/subdomain.dmz.rs.http /etc/nginx/sites-available/"$SUBDOMAIN".dmz.rs.http
mv /etc/nginx/sites-available/subdomain.dmz.rs.https /etc/nginx/sites-available/"$SUBDOMAIN".dmz.rs.https mv /etc/nginx/sites-available/subdomain.dmz.rs.https /etc/nginx/sites-available/"$SUBDOMAIN".dmz.rs.https

View File

@ -0,0 +1,29 @@
server {
listen 443 ssl ;
listen [::]:443 ssl ;
index index.html index.htm index.nginx-debian.html;
server_name subdomain.dmz.rs subdomain.decentrala.org;
ssl_certificate /etc/letsencrypt/live/subdomain.dmz.rs/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/subdomain.dmz.rs/privkey.pem;
ssl_dhparam /etc/ssl/dhparam.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
proxy_set_header Host azuracast.dckrov.rs;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://CTIPADDRESS$request_uri;
}
location /.well-known/acme-challenge/ {
root /var/www/subnodotdmzrs;
}
resolver 9.9.9.9;
}