X-Git-Url: https://iankelling.org/git/?p=basic-https-conf;a=blobdiff_plain;f=nginx-site;h=addd1d4a277740f60e683f1d5be529844ab72be9;hp=f66b40c86b40db48d0601a287abe2f7dcecbaaa8;hb=79707a58470ef41c8b1f07d1b9fb5b4cbfe46c6c;hpb=3139f7f6b990e8ca3aa491078e3496dc97dc4c36 diff --git a/nginx-site b/nginx-site index f66b40c..addd1d4 100755 --- a/nginx-site +++ b/nginx-site @@ -31,9 +31,9 @@ location for storing certs. EXTRA_SETTINGS_FILE can be - for stdin -c CERT_DIR In priority: this arg, $ACME_TINY_WRAPPER_CERT_DIR, $HOME/webservercerts, if the other options aren't set. +-f [ADDR:]PORT Enable proxy to [ADDR:]PORT. ADDR default is 127.0.0.1 -p PORT Port to listen on, default 443 --f PORT Enable proxy to PORT on localhost --r DocumentRoot +-r DIR DocumentRoot -h|--help Print help and exit TODO: add https redir site. @@ -50,15 +50,14 @@ if [[ ! $cert_dir ]]; then cert_dir=$HOME/webservercerts fi port=443 -proxy_port= extra_settings= temp=$(getopt -l help: c:f:p:r:h "$@") || usage 1 eval set -- "$temp" while true; do case $1 in -c) cert_dir="$2"; shift 2 ;; + -f) proxy="$2"; shift 2 ;; -p) port="$2"; shift 2 ;; - -f) proxy_port="$2"; shift 2 ;; -r) root="$2"; shift 2 ;; --) shift; break ;; -h|--help) usage ;; @@ -81,16 +80,21 @@ if [[ ! $root ]]; then root=/var/www/$h/html fi +if [[ $proxy ]]; then + [[ $proxy == *:* ]] || proxy=127.0.0.1:$proxy +fi + ##### end command line parsing ######## -sudo rm -f /etc/nginx/sites-enabled/default +rm -f /etc/nginx/sites-enabled/default if nginx -V |& grep -- '--with-http_v2_module\b' &>/dev/null; then http2_arg=http2 fi -sudo dd of=/etc/nginx/sites-enabled/$h.conf </etc/nginx/sites-enabled/$h.conf <; EOF if [[ $extra_settings ]]; then - cat $extra_settings | sudo tee -a /etc/nginx/sites-enabled/$h.conf + cat $extra_settings >>/etc/nginx/sites-enabled/$h.conf fi -if [[ $proxy_port ]]; then - sudo tee -a /etc/nginx/sites-enabled/$h.conf <>/etc/nginx/sites-enabled/$h.conf <>/etc/nginx/sites-enabled/$h.conf <