X-Git-Url: https://iankelling.org/git/?p=basic-https-conf;a=blobdiff_plain;f=web-conf;h=08d1c047f2bd649da80745acc075af18359a10a2;hp=b953668ee5a6ad797ea92e8407e25356fb0c9c38;hb=43857c512f612e094ae9fe49c47892f0ba1abd30;hpb=6761d31c8b47efb9361c0d8b69eda24da97769fa diff --git a/web-conf b/web-conf index b953668..08d1c04 100755 --- a/web-conf +++ b/web-conf @@ -33,7 +33,7 @@ EXTRA_SETTINGS_FILE can be - for stdin root@\$(hostname -A|awk '{print $1}') which is root@$(hostname -A|awk '{print $1}') on this host. -f [ADDR:]PORT Enable proxy to [ADDR:]PORT. ADDR default is 127.0.0.1 --i Insecure, no ssl. Not implemented for nginx. +-i Insecure, no ssl. -p PORT Main port to listen on, default 443. 80 implies -i. -r DIR DocumentRoot -h|--help Print help and exit @@ -112,8 +112,10 @@ if $ssl; then f=$cert_dir/fullchain.pem if [[ ! -e $f ]] || openssl x509 -checkend 86400 -noout -in $f; then $0 -p 80 $t $h - # adds every security option - certbot certonly -n --hsts --staple-ocsp --uir --must-staple --email $email --staple-ocsp --no-self-upgrade --agree-tos --apache -d $h + # when generating an example config, add all relevant security options: + # --hsts --staple-ocsp --uir + certbot certonly -n --must-staple --email $email --no-self-upgrade \ + --agree-tos --$t -d $h rm $vhost_file fi fi @@ -294,8 +296,12 @@ if [[ $t == nginx ]]; then cd /etc/nginx [[ -e dh2048.pem ]] || openssl dhparam -out dh2048.pem 2048 - if nginx -V |& grep -- '--with-http_v2_module\b' &>/dev/null; then - http2_arg=http2 + if $ssl; then + ssl_arg=ssl + if nginx -V |& grep -- '--with-http_v2_module\b' &>/dev/null; then + # fun fact: nginx can be configured to do http2 without ssl. + ssl_arg+=" http2" + fi fi cat >$common_ssl_conf <<'EOF' @@ -333,14 +339,27 @@ EOF server { server_name $h www.$h; root $root; - listen $port ssl $http2_arg; - listen [::]:$port ssl $http2_arg; + listen $port $ssl_arg; + listen [::]:$port $ssl_arg; - # certs sent to the client in SERVER HELLO are concatenated in ssl_certificate +EOF + if $ssl; then + cat >>$vhost_file <$redir_file <>$vhost_file fi @@ -362,14 +381,6 @@ EOF } EOF - cat >$redir_file <