From 43857c512f612e094ae9fe49c47892f0ba1abd30 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Wed, 26 Apr 2017 08:52:57 -0700 Subject: [PATCH] fix nginx, add non ssl --- web-conf | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) 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 <