From bc1b27a504bc0db821424d33f168c3d7787ced9c Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 24 Aug 2023 18:15:01 +1000 Subject: [PATCH] worker: Fixed ports --- worker/main.py | 6 +++--- worker/wp.sh | 23 +++++++++-------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/worker/main.py b/worker/main.py index f24852a..82e4a18 100644 --- a/worker/main.py +++ b/worker/main.py @@ -26,7 +26,7 @@ def new_site(): sites_file.close() # New site in background - thread = threading.Thread(target=new_site, args=(domain, 5000 + count)) + thread = threading.Thread(target=new_site, args=(domain)) thread.start() @@ -93,8 +93,8 @@ def site_exists(domain): else: return False -def new_site(domain,port): - script = 'bash wp.sh ' + domain + ' '+ str(port) +def new_site(domain): + script = 'bash wp.sh ' + domain os.system(script) # Start the server diff --git a/worker/wp.sh b/worker/wp.sh index 6563699..227ddae 100644 --- a/worker/wp.sh +++ b/worker/wp.sh @@ -4,10 +4,8 @@ # Then it will create an NGINX reverse proxy to the container. # USAGE: -# ./wp.sh [domain] [port offset] +# ./wp.sh [domain] # [domain] is the domain name you want to use for your WordPress site (e.g. docker.freeconcept) -# [port offset] is the offset you want to use for the port numbers. -# This is used if you want to run multiple instances of WordPress on the same server. (e.g. 0, 1, 2, 3, etc.) # Variables # Set the domain name @@ -21,15 +19,6 @@ fi DOMAIN="$1" echo "Setting up on domain name: $DOMAIN" -# Set port offset -# This is used to offset the port numbers so you can run multiple instances of WordPress on the same server. -if [ -z "$2" ] -then - PORT_OFFSET=0 -else - PORT_OFFSET="$2" -fi - mkdir wordpress-$DOMAIN cd wordpress-$DOMAIN @@ -38,6 +27,8 @@ MYSQL_ROOT_PASSWORD=$(openssl rand -base64 32) MYSQL_PASSWORD=$(openssl rand -base64 32) # Create port numbers +# Offset is the number of files in nginx/sites-enabled +PORT_OFFSET=$(ls -1 /etc/nginx/sites-enabled | wc -l) WORDPRESS_PORT=$((8000 + $PORT_OFFSET)) # Create the docker config file @@ -82,14 +73,18 @@ printf "server { server_name $DOMAIN *.$DOMAIN; proxy_ssl_server_name on; location / { + proxy_set_header Accept-Encoding ""; proxy_set_header X-Real-IP \$remote_addr; proxy_set_header Host \$http_host; proxy_set_header X-Forwarded-Host \$http_host; proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto \$scheme; - proxy_pass $URL; - } + + sub_filter '' ''; + sub_filter_once on; + + } listen 443 ssl; ssl_certificate /etc/ssl/$DOMAIN.crt;