cloud-apache-container/scripts/create-vhost.sh

49 lines
1.0 KiB
Bash
Raw Normal View History

2023-04-05 14:53:20 +00:00
#!/bin/bash
alias_block=''
#Create Server Alias Block
if [ ! -z $serveralias ]; then
for alias in $(echo $serveralias | tr ',' ' ')
do
alias_block=$alias_block"ServerAlias $alias
"
done
fi
cat <<EOF > /etc/httpd/conf.d/$domain.conf
<Directory "/home/$user">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
<Directory "/home/$user/public_html">
Options All MultiViews
AllowOverride All
Require all granted
</Directory>
<VirtualHost _default_:*>
ServerName "$domain"
$alias_block
DocumentRoot "/home/$user/public_html"
RewriteEngine on
RewriteCond %{SERVER_NAME} =$domain
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerName "$domain"
$alias_block
DocumentRoot "/home/$user/public_html"
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
</VirtualHost>
</IfModule>
EOF