#!/bin/bash alias_block='' # ---- 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 cat < /etc/httpd/conf.d/$domain.conf AllowOverride None # Allow open access: Require all granted Options All MultiViews AllowOverride All Require all granted ServerName "$domain" $alias_block DocumentRoot "/home/$user/public_html" RewriteEngine on RewriteCond %{SERVER_NAME} =$domain RewriteRule ^ https://%{SERVER_NAME}${https_port_part}%{REQUEST_URI} [END,NE,R=permanent] Listen 443 https SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog SSLSessionCache shmcb:/run/httpd/sslcache(512000) SSLSessionCacheTimeout 300 SSLCryptoDevice builtin ServerName "$domain" $alias_block DocumentRoot "/home/$user/public_html" SSLCertificateFile /etc/pki/tls/certs/localhost.crt SSLCertificateKeyFile /etc/pki/tls/private/localhost.key EOF