X-Git-Url: https://iankelling.org/git/?p=basic-https-conf;a=blobdiff_plain;f=apache-site;h=8ff08b8d63594bdffd2dbb19dea991d31cf41a3f;hp=f537369ea2b1c9355d3c95cced18e582c54036fc;hb=79707a58470ef41c8b1f07d1b9fb5b4cbfe46c6c;hpb=b6d31ac103c53debe4ad59fd34f63c1ca1a5e846 diff --git a/apache-site b/apache-site index f537369..8ff08b8 100755 --- a/apache-site +++ b/apache-site @@ -18,19 +18,22 @@ set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR +shopt -s nullglob # used in apache config file expansion + usage() { cat <$vhost_file < + ServerName $h ServerAlias www.$h DocumentRoot $root EOF if [[ $extra_settings ]]; then - cat -- $extra_settings | tee -a $vhost_file + cat -- $extra_settings >>$vhost_file fi # go faster! if [[ -e /etc/apache2/mods-available/http2.load ]]; then # https://httpd.apache.org/docs/2.4/mod/mod_http2.html a2enmod http2 -tee -a $vhost_file <>$vhost_file <>$vhost_file <>$vhost_file <$redir_file <<'EOF' # vhost_combined with %D (request time in microseconds) # this file is just a convenient place to drop it. LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %D" vhost_time_combined @@ -140,11 +202,18 @@ RewriteEngine on RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent] EOF + if ! $listen_80; then + cat >>$redir_file <<'EOF' +Listen 80 +EOF + fi + fi mkdir -p /etc/letsencrypt # this is from cerbot, see below. - cat >$certbot_ssl_conf <<'EOF' + echo "$0: creating $certbot_ssl_conf" + cat >$certbot_ssl_conf <<'EOF' # Baseline setting to Include for SSL sites SSLEngine on @@ -184,14 +253,21 @@ Update this script to take care this warning!!!!! EOF sleep 1 fi -fi -tee -a $vhost_file <>$vhost_file < +EOF -# vim: syntax=apache ts=4 sw=4 sts=4 sr noet +if ! $listen_port; then + # reference: https://httpd.apache.org/docs/2.4/mod/mpm_common.html#listen + cat >>$vhost_file <