From d44faac00ed9dda9d1ba82b2481dcdc42ec8ee79 Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Thu, 21 Jul 2022 15:25:10 -0700 Subject: [PATCH] add ForceHTTPS option variable --- etc/apache2/mods-available/macro.conf | 47 ++++++++++++++++----------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/etc/apache2/mods-available/macro.conf b/etc/apache2/mods-available/macro.conf index 7911495..3ea4a8b 100644 --- a/etc/apache2/mods-available/macro.conf +++ b/etc/apache2/mods-available/macro.conf @@ -22,6 +22,9 @@ # Uncomment and change example.com to suit your needs. #Define AliasDomain example.com +# Uncomment to force redirect from http to https for all VirtualHost that have HTTPS enabled +Define ForceHTTPS + # VHostHTTP - HTTP on Port 80 @@ -47,7 +50,7 @@ ServerAlias $subdomain.$vhost.${AliasDomain} - DocumentRoot /srv/www/$vhost/$subdomain + DocumentRoot /srv/www/$vhost/html/$subdomain SetHandler "proxy:unix:/run/php/php7.4-fpm-$username.sock|fcgi://localhost" @@ -67,11 +70,13 @@ RewriteEngine on RewriteCond %{REQUEST_URI} ^/cgi-bin/.* RewriteRule ^/cgi-bin/(.*) /cgi-wrap/cgiwrap/$username/$1 [PT] -## -## -## Redirect 301 "https://%{HTTP_HOST}%{REQUEST_URI}" -## -## + + + + Redirect 301 "https://%{HTTP_HOST}%{REQUEST_URI}" + + + SetHandler "proxy:unix:/run/php/php7.4-fpm-$username.sock|fcgi://localhost" @@ -115,12 +120,14 @@ ServerAlias $subdomain.$vhost.${AliasDomain} - DocumentRoot /srv/www/$vhost/$subdomain -## -## -## Redirect 301 "https://%{HTTP_HOST}%{REQUEST_URI}" -## -## + DocumentRoot /srv/www/$vhost/html/$subdomain + + + + Redirect 301 "https://%{HTTP_HOST}%{REQUEST_URI}" + + + SetHandler "proxy:unix:/run/php/php7.4-fpm-$username.sock|fcgi://localhost" @@ -130,7 +137,7 @@ ServerAlias $subdomain.$vhost.${AliasDomain} - DocumentRoot /srv/www/$vhost/$subdomain + DocumentRoot /srv/www/$vhost/html/$subdomain SetHandler "proxy:unix:/run/php/php7.4-fpm-$username.sock|fcgi://localhost" @@ -178,7 +185,7 @@ ServerAlias $subdomain.$vhost.${AliasDomain} - DocumentRoot /srv/www/$vhost/$subdomain + DocumentRoot /srv/www/$vhost/html/$subdomain SetHandler "proxy:unix:/run/php/php7.4-fpm-$username.sock|fcgi://localhost" @@ -289,11 +296,13 @@ RewriteEngine on RewriteCond %{REQUEST_URI} ^/cgi-bin/.* RewriteRule ^/cgi-bin/(.*) /cgi-wrap/cgiwrap/$username/$1 [PT] -## -## -## Redirect 301 "https://%{HTTP_HOST}%{REQUEST_URI}" -## -## + + + + Redirect 301 "https://%{HTTP_HOST}%{REQUEST_URI}" + + + SetHandler "proxy:unix:/run/php/php7.4-fpm-$username.sock|fcgi://localhost"