add ForceHTTPS option variable

This commit is contained in:
Matthew Saunders Brown 2022-07-21 15:25:10 -07:00
parent 4d57865ae9
commit d44faac00e

View File

@ -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
<Macro VHostHTTP $vhost $username>
<VirtualHost *:80>
@ -47,7 +50,7 @@
<IfDefine AliasDomain>
ServerAlias $subdomain.$vhost.${AliasDomain}
</IfDefine>
DocumentRoot /srv/www/$vhost/$subdomain
DocumentRoot /srv/www/$vhost/html/$subdomain
<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler "proxy:unix:/run/php/php7.4-fpm-$username.sock|fcgi://localhost"
</FilesMatch>
@ -67,11 +70,13 @@
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/cgi-bin/.*
RewriteRule ^/cgi-bin/(.*) /cgi-wrap/cgiwrap/$username/$1 [PT]
## <Location "/">
## <If "%{REQUEST_URI} !~ m#^/.well-known/acme-challenge/#">
## Redirect 301 "https://%{HTTP_HOST}%{REQUEST_URI}"
## </If>
## </Location>
<IfDefine ForceHTTPS>
<Location "/">
<If "%{REQUEST_URI} !~ m#^/.well-known/acme-challenge/#">
Redirect 301 "https://%{HTTP_HOST}%{REQUEST_URI}"
</If>
</Location>
</IfDefine>
<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler "proxy:unix:/run/php/php7.4-fpm-$username.sock|fcgi://localhost"
</FilesMatch>
@ -115,12 +120,14 @@
<IfDefine AliasDomain>
ServerAlias $subdomain.$vhost.${AliasDomain}
</IfDefine>
DocumentRoot /srv/www/$vhost/$subdomain
## <Location "/">
## <If "%{REQUEST_URI} !~ m#^/.well-known/acme-challenge/#">
## Redirect 301 "https://%{HTTP_HOST}%{REQUEST_URI}"
## </If>
## </Location>
DocumentRoot /srv/www/$vhost/html/$subdomain
<IfDefine ForceHTTPS>
<Location "/">
<If "%{REQUEST_URI} !~ m#^/.well-known/acme-challenge/#">
Redirect 301 "https://%{HTTP_HOST}%{REQUEST_URI}"
</If>
</Location>
</IfDefine>
<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler "proxy:unix:/run/php/php7.4-fpm-$username.sock|fcgi://localhost"
</FilesMatch>
@ -130,7 +137,7 @@
<IfDefine AliasDomain>
ServerAlias $subdomain.$vhost.${AliasDomain}
</IfDefine>
DocumentRoot /srv/www/$vhost/$subdomain
DocumentRoot /srv/www/$vhost/html/$subdomain
<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler "proxy:unix:/run/php/php7.4-fpm-$username.sock|fcgi://localhost"
</FilesMatch>
@ -178,7 +185,7 @@
<IfDefine AliasDomain>
ServerAlias $subdomain.$vhost.${AliasDomain}
</IfDefine>
DocumentRoot /srv/www/$vhost/$subdomain
DocumentRoot /srv/www/$vhost/html/$subdomain
<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler "proxy:unix:/run/php/php7.4-fpm-$username.sock|fcgi://localhost"
</FilesMatch>
@ -289,11 +296,13 @@
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/cgi-bin/.*
RewriteRule ^/cgi-bin/(.*) /cgi-wrap/cgiwrap/$username/$1 [PT]
## <Location "/">
## <If "%{REQUEST_URI} !~ m#^/.well-known/acme-challenge/#">
## Redirect 301 "https://%{HTTP_HOST}%{REQUEST_URI}"
## </If>
## </Location>
<IfDefine ForceHTTPS>
<Location "/">
<If "%{REQUEST_URI} !~ m#^/.well-known/acme-challenge/#">
Redirect 301 "https://%{HTTP_HOST}%{REQUEST_URI}"
</If>
</Location>
</IfDefine>
<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler "proxy:unix:/run/php/php7.4-fpm-$username.sock|fcgi://localhost"
</FilesMatch>