alias macro fixes

This commit is contained in:
Matthew Saunders Brown 2021-10-05 13:22:39 -07:00
parent 8c68b39834
commit 4bba0e9cc4
2 changed files with 19 additions and 21 deletions

View File

@ -18,6 +18,8 @@ help()
echo " -d <domain> Domain name of VirtualHost to remove." echo " -d <domain> Domain name of VirtualHost to remove."
echo " -m <macro> Name of Apache macro to apply." echo " -m <macro> Name of Apache macro to apply."
echo " -o <option> Subdomain or Alias or Redirect URL if specified macro requires one." echo " -o <option> Subdomain or Alias or Redirect URL if specified macro requires one."
echo " For Alias domains '-d <domain>' is the alias domain, and '-o <alias>'"
echo " is the existing VirtualHost to alias to."
echo "" echo ""
echo " Available Apache Macros:" echo " Available Apache Macros:"
echo "" echo ""
@ -121,8 +123,8 @@ if [[ "$macro" == *"VHost"* ]]; then
if [ -n $option ]; then if [ -n $option ]; then
alias=$option alias=$option
# make sure Alias domain isn't already installed as it's own vhost # make sure Alias domain isn't already installed as it's own vhost
if [ -d "/srv/www/$alias" ]; then if [ -d "/srv/www/$domain" ]; then
echo "$alias is already installed as it's own vhost" echo "$domain is already installed as it's own vhost"
exit 1 exit 1
else else
macro_vhost_line="$macro_vhost_line $alias" macro_vhost_line="$macro_vhost_line $alias"
@ -164,13 +166,9 @@ fi
# if https check for le cert # if https check for le cert
if [[ "$macro" == *"HTTPS"* ]]; then if [[ "$macro" == *"HTTPS"* ]]; then
if [[ "$macro" == *"Alias"* ]]; then cert_host=$domain
cert_host="$alias" if [[ "$macro" == *"Subdomain"* ]]; then
else cert_host="$subdomain.$cert_host"
cert_host=$domain
if [[ "$macro" == *"Subdomain"* ]]; then
cert_host="$subdomain.$cert_host"
fi
fi fi
if [[ ! -f "/etc/ssl/letsencrypt/$cert_host.pem" ]]; then if [[ ! -f "/etc/ssl/letsencrypt/$cert_host.pem" ]]; then
echo "cert file for $cert_host does not exist" echo "cert file for $cert_host does not exist"

View File

@ -201,10 +201,10 @@
<Macro VHostAliasHTTP $vhost $username $alias> <Macro VHostAliasHTTP $vhost $username $alias>
<VirtualHost *:80> <VirtualHost *:80>
ServerName $alias ServerName $vhost
ServerAlias www.$alias ServerAlias www.$vhost
ServerAlias $alias.example.com ServerAlias $vhost.example.com
DocumentRoot /srv/www/$vhost/html DocumentRoot /srv/www/$alias/html
<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>
@ -213,10 +213,10 @@
<Macro VHostAliasHTTPS $vhost $username $alias> <Macro VHostAliasHTTPS $vhost $username $alias>
<VirtualHost *:80> <VirtualHost *:80>
ServerName $alias ServerName $vhost
ServerAlias www.$alias ServerAlias www.$vhost
ServerAlias $alias.example.com ServerAlias $vhost.example.com
DocumentRoot /srv/www/$vhost/html DocumentRoot /srv/www/$alias/html
## <Location "/"> ## <Location "/">
## <If "%{REQUEST_URI} !~ m#^/.well-known/acme-challenge/#"> ## <If "%{REQUEST_URI} !~ m#^/.well-known/acme-challenge/#">
## Redirect 301 "https://%{HTTP_HOST}%{REQUEST_URI}" ## Redirect 301 "https://%{HTTP_HOST}%{REQUEST_URI}"
@ -227,10 +227,10 @@
</FilesMatch> </FilesMatch>
</VirtualHost> </VirtualHost>
<VirtualHost *:443> <VirtualHost *:443>
ServerName $alias ServerName $vhost
ServerAlias www.$alias ServerAlias www.$vhost
ServerAlias $alias.example.com ServerAlias $vhost.example.com
DocumentRoot /srv/www/$vhost/html DocumentRoot /srv/www/$alias/html
<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>