2023-04-05 07:53:20 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
alias_block=''
|
|
|
|
|
|
2026-11-23 06:03:24 -08:00
|
|
|
# ---- HTTP -> HTTPS redirect keeps a non-standard HTTPS port (DEV only, set by
|
|
|
|
|
# local-dev.sh from -s). Without it a `-s 8443` mapping is redirected to
|
|
|
|
|
# https://host/ (port 443) and breaks. Unset, non-DEV or 443 = unchanged bytes.
|
|
|
|
|
https_port_part=''
|
|
|
|
|
if [ "${environment:-}" = "DEV" ] && [[ "${PUBLIC_HTTPS_PORT:-}" =~ ^[0-9]{1,5}$ ]] && [ "$PUBLIC_HTTPS_PORT" != "443" ]; then
|
|
|
|
|
https_port_part=":$PUBLIC_HTTPS_PORT"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
#Create Server Alias Block
|
|
|
|
|
if [ ! -z $serveralias ]; then
|
|
|
|
|
for alias in $(echo $serveralias | tr ',' ' ')
|
|
|
|
|
do
|
|
|
|
|
alias_block=$alias_block"ServerAlias $alias
|
|
|
|
|
"
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
|
2023-04-05 07:53:20 -07:00
|
|
|
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
|
2026-11-23 06:03:24 -08:00
|
|
|
RewriteRule ^ https://%{SERVER_NAME}${https_port_part}%{REQUEST_URI} [END,NE,R=permanent]
|
2023-04-05 07:53:20 -07:00
|
|
|
</VirtualHost>
|
|
|
|
|
|
2024-10-14 19:30:51 -07:00
|
|
|
Listen 443 https
|
|
|
|
|
SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog
|
|
|
|
|
SSLSessionCache shmcb:/run/httpd/sslcache(512000)
|
|
|
|
|
SSLSessionCacheTimeout 300
|
|
|
|
|
SSLCryptoDevice builtin
|
|
|
|
|
|
2023-04-05 07:53:20 -07:00
|
|
|
<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
|