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