From ba3b45a8c8a7c9e1c041a36dcab540d0a8439037 Mon Sep 17 00:00:00 2001 From: tbergervoet Date: Tue, 25 Sep 2018 13:45:16 +0000 Subject: [PATCH] Update 'RevProxySimple.sh' --- RevProxySimple.sh | 48 ++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/RevProxySimple.sh b/RevProxySimple.sh index a667437..fc39561 100644 --- a/RevProxySimple.sh +++ b/RevProxySimple.sh @@ -11,6 +11,8 @@ # Pre-Config # ##----------------## +# Set server IP variable for apache access +server_ip=$(hostname -I|cut -f1 -d ' ') # Block direct apache acces ufw deny 8080/tcp # Setup domain folder @@ -35,28 +37,32 @@ mysql -u root -p"$password" -e "SELECT user,authentication_string,plugin,host FR rm /etc/nginx/sites-enabled/default cat < /etc/nginx/sites-available/"$domain" server { - listen 80; + listen 80; + server_name $domain www.$domain; + root /var/www/$domain/html/; + index index.php index.htm index.html; + + location / { + try_files \$uri \$uri/ /index.php; + } - root /var/www/$domain/html; - index index.html index.htm index.php; - - server_name $domain www.$domain; - - location / { - try_files \$uri \$uri/ /index.php; - } - - location ~ \.php\$ { - proxy_redirect off; - proxy_set_header X-Real-IP \$remote_addr; - proxy_set_header X-Forwarded-For \$remote_addr; - proxy_set_header Host \$host; - proxy_pass http://127.0.0.1:8080; - } - - location ~ /\.ht { - deny all; - } + location ~ \.php\$ { + proxy_pass http://$server_ip:8080; + proxy_set_header Host \$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 \$scheme; + } + + location ~ /\.ht { + deny all; + } + + #listen 443 ssl; + #ssl_certificate /etc/letsencrypt/live/$domain/fullchain.pem; + #ssl_certificate_key /etc/letsencrypt/live/$domain/privkey.pem; + #include /etc/letsencrypt/options-ssl-nginx.conf; + #ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; } EOF ln -s /etc/nginx/sites-available/"$domain" /etc/nginx/sites-enabled/"$domain"