add AliasDomain variable

This commit is contained in:
Matthew Saunders Brown 2022-07-21 15:06:41 -07:00
parent 7197d9379e
commit 4d57865ae9

View File

@ -17,12 +17,19 @@
# VHostAliasHTTPSVarnish for http & https # VHostAliasHTTPSVarnish for http & https
# *only use one of the Alias options above at at time* # *only use one of the Alias options above at at time*
# VHostHTTP - HTTP on Port 80. Includes ServerAlias for .example.com subdomain
# Optional AliasDomain for accessing VirtualHosts.
# Uncomment and change example.com to suit your needs.
#Define AliasDomain example.com
# VHostHTTP - HTTP on Port 80
<Macro VHostHTTP $vhost $username> <Macro VHostHTTP $vhost $username>
<VirtualHost *:80> <VirtualHost *:80>
ServerName $vhost ServerName $vhost
ServerAlias www.$vhost ServerAlias www.$vhost
ServerAlias $vhost.example.com <IfDefine AliasDomain>
ServerAlias $vhost.${AliasDomain}
</IfDefine>
DocumentRoot /srv/www/$vhost/html DocumentRoot /srv/www/$vhost/html
ScriptAlias /cgi-wrap/ "/usr/local/lib/cgi-wrap/$vhost/" ScriptAlias /cgi-wrap/ "/usr/local/lib/cgi-wrap/$vhost/"
RewriteEngine on RewriteEngine on
@ -37,7 +44,9 @@
<Macro VHostSubdomainHTTP $vhost $username $subdomain> <Macro VHostSubdomainHTTP $vhost $username $subdomain>
<VirtualHost *:80> <VirtualHost *:80>
ServerName $subdomain.$vhost ServerName $subdomain.$vhost
ServerAlias $subdomain.$vhost.example.com <IfDefine AliasDomain>
ServerAlias $subdomain.$vhost.${AliasDomain}
</IfDefine>
DocumentRoot /srv/www/$vhost/$subdomain DocumentRoot /srv/www/$vhost/$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"
@ -45,12 +54,14 @@
</VirtualHost> </VirtualHost>
</Macro> </Macro>
# VHostHTTPS - HTTPS on Port 443. Inludes Port 80 and ServerAliases for .example.com subdomain # VHostHTTPS - HTTPS on Port 443. Inludes Port 80 and ServerAliases for ${AliasDomain} subdomain
<Macro VHostHTTPS $vhost $username> <Macro VHostHTTPS $vhost $username>
<VirtualHost *:80> <VirtualHost *:80>
ServerName $vhost ServerName $vhost
ServerAlias www.$vhost ServerAlias www.$vhost
ServerAlias $vhost.example.com <IfDefine AliasDomain>
ServerAlias $vhost.${AliasDomain}
</IfDefine>
DocumentRoot /srv/www/$vhost/html DocumentRoot /srv/www/$vhost/html
ScriptAlias /cgi-wrap/ "/usr/local/lib/cgi-wrap/$vhost/" ScriptAlias /cgi-wrap/ "/usr/local/lib/cgi-wrap/$vhost/"
RewriteEngine on RewriteEngine on
@ -68,7 +79,9 @@
<VirtualHost *:443> <VirtualHost *:443>
ServerName $vhost ServerName $vhost
ServerAlias www.$vhost ServerAlias www.$vhost
ServerAlias $vhost.example.com <IfDefine AliasDomain>
ServerAlias $vhost.${AliasDomain}
</IfDefine>
DocumentRoot /srv/www/$vhost/html DocumentRoot /srv/www/$vhost/html
ScriptAlias /cgi-wrap/ "/usr/local/lib/cgi-wrap/$vhost/" ScriptAlias /cgi-wrap/ "/usr/local/lib/cgi-wrap/$vhost/"
RewriteEngine on RewriteEngine on
@ -95,11 +108,13 @@
</VirtualHost> </VirtualHost>
</Macro> </Macro>
# VHostSubdomainHTTPS - HTTPS on Port 443. Inludes Port 80 and ServerAliases for .example.com subdomain # VHostSubdomainHTTPS - HTTPS on Port 443. Inludes Port 80 and ServerAliases for ${AliasDomain} subdomain
<Macro VHostSubdomainHTTPS $vhost $username $subdomain> <Macro VHostSubdomainHTTPS $vhost $username $subdomain>
<VirtualHost *:80> <VirtualHost *:80>
ServerName $subdomain.$vhost ServerName $subdomain.$vhost
ServerAlias $subdomain.$vhost.example.com <IfDefine AliasDomain>
ServerAlias $subdomain.$vhost.${AliasDomain}
</IfDefine>
DocumentRoot /srv/www/$vhost/$subdomain DocumentRoot /srv/www/$vhost/$subdomain
## <Location "/"> ## <Location "/">
## <If "%{REQUEST_URI} !~ m#^/.well-known/acme-challenge/#"> ## <If "%{REQUEST_URI} !~ m#^/.well-known/acme-challenge/#">
@ -112,7 +127,9 @@
</VirtualHost> </VirtualHost>
<VirtualHost *:443> <VirtualHost *:443>
ServerName $subdomain.$vhost ServerName $subdomain.$vhost
ServerAlias $subdomain.$vhost.example.com <IfDefine AliasDomain>
ServerAlias $subdomain.$vhost.${AliasDomain}
</IfDefine>
DocumentRoot /srv/www/$vhost/$subdomain DocumentRoot /srv/www/$vhost/$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"
@ -127,7 +144,9 @@
<VirtualHost *:80> <VirtualHost *:80>
ServerName $vhost ServerName $vhost
ServerAlias www.$vhost ServerAlias www.$vhost
ServerAlias $vhost.example.com <IfDefine AliasDomain>
ServerAlias $vhost.${AliasDomain}
</IfDefine>
DocumentRoot /srv/www/$vhost/html DocumentRoot /srv/www/$vhost/html
ScriptAlias /cgi-wrap/ "/usr/local/lib/cgi-wrap/$vhost/" ScriptAlias /cgi-wrap/ "/usr/local/lib/cgi-wrap/$vhost/"
RewriteEngine on RewriteEngine on
@ -140,7 +159,9 @@
<VirtualHost *:443> <VirtualHost *:443>
ServerName $vhost ServerName $vhost
ServerAlias www.$vhost ServerAlias www.$vhost
ServerAlias $vhost.example.com <IfDefine AliasDomain>
ServerAlias $vhost.${AliasDomain}
</IfDefine>
RequestHeader set X-Forwarded-Proto https RequestHeader set X-Forwarded-Proto https
ProxyPreserveHost On ProxyPreserveHost On
ProxyPass / http://127.0.0.1:6081/ ProxyPass / http://127.0.0.1:6081/
@ -154,7 +175,9 @@
<Macro VHostSubdomainHTTPSVarnish $vhost $username $subdomain> <Macro VHostSubdomainHTTPSVarnish $vhost $username $subdomain>
<VirtualHost *:80> <VirtualHost *:80>
ServerName $subdomain.$vhost ServerName $subdomain.$vhost
ServerAlias $subdomain.$vhost.example.com <IfDefine AliasDomain>
ServerAlias $subdomain.$vhost.${AliasDomain}
</IfDefine>
DocumentRoot /srv/www/$vhost/$subdomain DocumentRoot /srv/www/$vhost/$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"
@ -162,7 +185,9 @@
</VirtualHost> </VirtualHost>
<VirtualHost *:443> <VirtualHost *:443>
ServerName $subdomain.$vhost ServerName $subdomain.$vhost
ServerAlias $subdomain.$vhost.example.com <IfDefine AliasDomain>
ServerAlias $subdomain.$vhost.${AliasDomain}
</IfDefine>
RequestHeader set X-Forwarded-Proto https RequestHeader set X-Forwarded-Proto https
ProxyPreserveHost On ProxyPreserveHost On
ProxyPass / http://127.0.0.1:6081/ ProxyPass / http://127.0.0.1:6081/
@ -194,7 +219,9 @@
<VirtualHost *:80> <VirtualHost *:80>
ServerName $vhost ServerName $vhost
ServerAlias www.$vhost ServerAlias www.$vhost
ServerAlias $vhost.example.com <IfDefine AliasDomain>
ServerAlias $vhost.${AliasDomain}
</IfDefine>
<Location "/"> <Location "/">
<If "%{REQUEST_URI} !~ m#^/.well-known/acme-challenge/#"> <If "%{REQUEST_URI} !~ m#^/.well-known/acme-challenge/#">
Redirect 301 "$redirect%{REQUEST_URI}" Redirect 301 "$redirect%{REQUEST_URI}"
@ -207,7 +234,9 @@
<VirtualHost *:80> <VirtualHost *:80>
ServerName $vhost ServerName $vhost
ServerAlias www.$vhost ServerAlias www.$vhost
ServerAlias $vhost.example.com <IfDefine AliasDomain>
ServerAlias $vhost.${AliasDomain}
</IfDefine>
<Location "/"> <Location "/">
<If "%{REQUEST_URI} !~ m#^/.well-known/acme-challenge/#"> <If "%{REQUEST_URI} !~ m#^/.well-known/acme-challenge/#">
Redirect 301 "$redirect%{REQUEST_URI}" Redirect 301 "$redirect%{REQUEST_URI}"
@ -217,7 +246,9 @@
<VirtualHost *:443> <VirtualHost *:443>
ServerName $vhost ServerName $vhost
ServerAlias www.$vhost ServerAlias www.$vhost
ServerAlias $vhost.example.com <IfDefine AliasDomain>
ServerAlias $vhost.${AliasDomain}
</IfDefine>
<Location "/"> <Location "/">
<If "%{REQUEST_URI} !~ m#^/.well-known/acme-challenge/#"> <If "%{REQUEST_URI} !~ m#^/.well-known/acme-challenge/#">
Redirect 301 "$redirect%{REQUEST_URI}" Redirect 301 "$redirect%{REQUEST_URI}"
@ -232,7 +263,9 @@
<VirtualHost *:80> <VirtualHost *:80>
ServerName $vhost ServerName $vhost
ServerAlias www.$vhost ServerAlias www.$vhost
ServerAlias $vhost.example.com <IfDefine AliasDomain>
ServerAlias $vhost.${AliasDomain}
</IfDefine>
DocumentRoot /srv/www/$alias/html DocumentRoot /srv/www/$alias/html
ScriptAlias /cgi-wrap/ "/usr/local/lib/cgi-wrap/$alias/" ScriptAlias /cgi-wrap/ "/usr/local/lib/cgi-wrap/$alias/"
RewriteEngine on RewriteEngine on
@ -248,7 +281,9 @@
<VirtualHost *:80> <VirtualHost *:80>
ServerName $vhost ServerName $vhost
ServerAlias www.$vhost ServerAlias www.$vhost
ServerAlias $vhost.example.com <IfDefine AliasDomain>
ServerAlias $vhost.${AliasDomain}
</IfDefine>
DocumentRoot /srv/www/$alias/html DocumentRoot /srv/www/$alias/html
ScriptAlias /cgi-wrap/ "/usr/local/lib/cgi-wrap/$alias/" ScriptAlias /cgi-wrap/ "/usr/local/lib/cgi-wrap/$alias/"
RewriteEngine on RewriteEngine on
@ -266,7 +301,9 @@
<VirtualHost *:443> <VirtualHost *:443>
ServerName $vhost ServerName $vhost
ServerAlias www.$vhost ServerAlias www.$vhost
ServerAlias $vhost.example.com <IfDefine AliasDomain>
ServerAlias $vhost.${AliasDomain}
</IfDefine>
DocumentRoot /srv/www/$alias/html DocumentRoot /srv/www/$alias/html
ScriptAlias /cgi-wrap/ "/usr/local/lib/cgi-wrap/$alias/" ScriptAlias /cgi-wrap/ "/usr/local/lib/cgi-wrap/$alias/"
RewriteEngine on RewriteEngine on