diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index e30264a7..f0b4d384 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -279,11 +279,12 @@ STATUS(){ if [ "${STATUS_CHECK_EMAIL}" != "" ]; then echo "${NM_NODETYPES[$NTYPE]}-Node${nid} is back UP!" | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}-UP" ${STATUS_CHECK_EMAIL}; fi fi var2=${NTYPE}_REPL_CHECK[@] + timeout=`date --date='20 seconds' +%s` for rcheck in "${!var2}"; do if [ "${ST_ACTION}" != "check" ]; then c=0; cw=22; spc='' spc1=${cw}-${#REPL_DESC[${rcheck}]} - timeout=`date --date='20 seconds' +%s` + until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done echo -en " ${REPL_DESC[${rcheck}]}${spc}: " fi @@ -917,9 +918,9 @@ NEWSITE(){ echo "" if [ "${SITE_TYPE}" = "local" ]; then echo -e "server { - listen 8080;" > /etc/nginx/sites-available/${MAIN_SITE} + listen 80;" > /etc/nginx/sites-available/${MAIN_SITE} if [ "${CREATE_SSL}" = "yes" ]; then - echo -e " listen 8443 ssl http2;" >> /etc/nginx/sites-available/${MAIN_SITE} + echo -e " listen 443 ssl http2;" >> /etc/nginx/sites-available/${MAIN_SITE} fi echo -e " server_name ${NGINX_SERVERNAME}; @@ -957,13 +958,22 @@ NEWSITE(){ fi echo -e "}" >> /etc/nginx/sites-available/${MAIN_SITE} - for nip in "${MYSQL_HOSTS[@]}"; do - if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD='' - else NCMD="ssh root@${nip}" + + mkdir -p /var/www/${MAIN_SITE}/{public_html,nginx_logs} + echo -en "${idsCL[LightYellow]}Waiting for folder replication across the webserver nodes... ${idsCL[Default]}" + for nip in "${WEB_HOSTS[@]}"; do + if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) != *"${nip}"* ]]; then + checked=false + until [ "${checked}" = "" ]; do + checked=`ssh root@${nip} "[ ! -d /var/www/test ] && echo does not exist"` + done fi - ${NCMD} mkdir -p /var/www/${MAIN_SITE}/{public_html,nginx_logs} done + echo -e "${idsCL[Green]}Completed${idsCL[Default]}" + + echo -en "${idsCL[LightYellow]}Setting folder permissions... ${idsCL[Default]}" SET-PERMISSIONS ${MAIN_SITE} + echo -e "${idsCL[Green]}Completed${idsCL[Default]}" else @@ -972,9 +982,9 @@ NEWSITE(){ set \$server \"${PROXYHOST}\"; set \$port ${PROXYPORT}; - listen 8080;" > /etc/nginx/sites-available/${MAIN_SITE} + listen 80;" > /etc/nginx/sites-available/${MAIN_SITE} if [ "${CREATE_SSL}" = "yes" ]; then - echo -e " listen 8443 ssl http2;" >> /etc/nginx/sites-available/${MAIN_SITE} + echo -e " listen 443 ssl http2;" >> /etc/nginx/sites-available/${MAIN_SITE} fi echo -e " server_name ${NGINX_SERVERNAME};" >> /etc/nginx/sites-available/${MAIN_SITE} diff --git a/templates/nginx.site b/templates/nginx.site new file mode 100755 index 00000000..24e0e699 --- /dev/null +++ b/templates/nginx.site @@ -0,0 +1,23 @@ +server { + listen 80 proxy_protocol; + + server_name www.schroedercity.com; + set $base /var/www/SchroederCity; + root $base/public_html; + + access_log /var/log/nginx/www.schroedercity.com-access.log; + error_log /var/log/nginx/www.schroedercity.com-error.log warn; + + index index.php; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ \.php$ { + fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; + include conf.d/include/php_fastcgi.conf; + } + + include conf.d/include/general.conf; +} diff --git a/templates/nginx.ssl.site b/templates/nginx.ssl.site new file mode 100755 index 00000000..cd28240f --- /dev/null +++ b/templates/nginx.ssl.site @@ -0,0 +1,30 @@ +server { + listen 80 proxy_protocol; + listen 443 ssl http2 proxy_protocol; + + server_name www.schroedercity.com; + set $base /var/www/SchroederCity; + root $base/public_html; + + access_log /var/log/nginx/www.schroedercity.com-access.log; + error_log /var/log/nginx/www.schroedercity.com-error.log warn; + + ssl_certificate /etc/letsencrypt/live/www.schroedercity.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/www.schroedercity.com/privkey.pem; + include conf.d/include/ssl-ciphers.conf; + + index index.php; + + location / { + try_files $uri $uri/ /index.php?$query_string; + include conf.d/include/force-ssl.conf; + } + + location ~ \.php$ { + fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; + include conf.d/include/php_fastcgi.conf; + } + + include conf.d/include/general.conf; + include conf.d/include/letsencrypt-acme-challenge.conf; +}