From 3b44087ff35f8d4cd29cdbcffae267704460a4cf Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Tue, 9 Jul 2019 11:26:35 +0200 Subject: [PATCH] allow specification of additional domains with https support (#164) --- README.md | 1 + btcpay-setup.sh | 9 ++++++++- .../docker-fragments/btcpayserver-nginx.yml | 4 ++-- docker-compose-generator/docker-fragments/nginx.yml | 2 +- helpers.sh | 1 + 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1ed1cc2..719cd1a 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,7 @@ You can read [the article](https://medium.com/@BtcpayServer/hosting-btcpay-serve `btcpay-setup.sh` will use the following environment variables: * `BTCPAY_HOST`: The hostname of your website (eg. `btcpay.example.com`) +* `BTCPAY_ADDITIONAL_HOSTS`: Optional, specify additional domains to your BTCPayServer with https support if enabled. (eg. example2.com,example3.com) * `REVERSEPROXY_HTTP_PORT`: The public port the reverse proxy binds to for HTTP traffic (default: 80) * `REVERSEPROXY_HTTPS_PORT`: The public port the reverse proxy binds to for HTTPS traffic (default: 443) * `REVERSEPROXY_DEFAULT_HOST`: Optional, if using a reverse proxy nginx, specify which website should be presented if the server is accessed by its IP. diff --git a/btcpay-setup.sh b/btcpay-setup.sh index b7f608e..47c7236 100755 --- a/btcpay-setup.sh +++ b/btcpay-setup.sh @@ -97,6 +97,7 @@ Environment variables: BTCPAYGEN_DOCKER_IMAGE: Allows you to specify a custom docker image for the generator (Default: btcpayserver/docker-compose-generator) BTCPAY_IMAGE: Allows you to specify the btcpayserver docker image to use over the default version. (Default: current stable version of btcpayserver) BTCPAY_PROTOCOL: Allows you to specify the external transport protocol of BTCPayServer. (Default: https) + BTCPAY_ADDITIONAL_HOSTS: Allows you to specify additional domains to your BTCPayServer with https support if enabled. (eg. example2.com,example3.com) Add-on specific variables: LIBREPATRON_HOST: If libre patron is activated with opt-add-librepatron, the hostname of your libre patron website (eg. librepatron.example.com) WOOCOMMERCE_HOST: If woocommerce is activated with opt-add-woocommerce, the hostname of your woocommerce website (eg. store.example.com) @@ -142,7 +143,7 @@ while (( "$#" )); do esac done -# If start does not have a value, stophere +# If start does not have a value, stop here if ! [[ "$START" ]]; then display_help return @@ -160,6 +161,10 @@ if [[ -z "$BTCPAYGEN_CRYPTO1" ]]; then fi fi +if [ ! -z "$BTCPAY_ADDITIONAL_HOSTS" ] && [[ "$BTCPAY_ADDITIONAL_HOSTS" == *[';']* ]]; then + echo "$BTCPAY_ADDITIONAL_HOSTS should be separated by a , not ;" + return; +fi ######### Migration: old pregen environment to new environment ############ if [[ ! -z $BTCPAY_DOCKER_COMPOSE ]] && [[ ! -z $DOWNLOAD_ROOT ]] && [[ -z $BTCPAYGEN_OLD_PREGEN ]]; then echo "Your deployment is too old, you need to migrate by following instructions on this link https://github.com/btcpayserver/btcpayserver-docker/tree/master#i-deployed-before-btcpay-setupsh-existed-before-may-17-can-i-migrate-to-this-new-system" @@ -178,6 +183,7 @@ fi : "${REVERSEPROXY_DEFAULT_HOST:=none}" : "${ACME_CA_URI:=https://acme-v01.api.letsencrypt.org/directory}" : "${BTCPAY_PROTOCOL:=https}" +: "${BTCPAY_ADDITIONAL_HOSTS:=}" : "${REVERSEPROXY_HTTP_PORT:=80}" : "${REVERSEPROXY_HTTPS_PORT:=443}" @@ -229,6 +235,7 @@ echo " Parameters passed: BTCPAY_PROTOCOL:$BTCPAY_PROTOCOL BTCPAY_HOST:$BTCPAY_HOST +BTCPAY_ADDITIONAL_HOSTS:$BTCPAY_ADDITIONAL_HOSTS REVERSEPROXY_HTTP_PORT:$REVERSEPROXY_HTTP_PORT REVERSEPROXY_HTTPS_PORT:$REVERSEPROXY_HTTPS_PORT REVERSEPROXY_DEFAULT_HOST:$REVERSEPROXY_DEFAULT_HOST diff --git a/docker-compose-generator/docker-fragments/btcpayserver-nginx.yml b/docker-compose-generator/docker-fragments/btcpayserver-nginx.yml index 19af857..e502ff7 100644 --- a/docker-compose-generator/docker-fragments/btcpayserver-nginx.yml +++ b/docker-compose-generator/docker-fragments/btcpayserver-nginx.yml @@ -7,10 +7,10 @@ services: # NGINX settings VIRTUAL_NETWORK: nginx-proxy VIRTUAL_PORT: 49392 - VIRTUAL_HOST: ${BTCPAY_HOST} + VIRTUAL_HOST: ${BTCPAY_HOST},${BTCPAY_ADDITIONAL_HOSTS} VIRTUAL_HOST_NAME: "btcpay" SSL_POLICY: Mozilla-Modern # Let's encrypt settings - LETSENCRYPT_HOST: ${BTCPAY_HOST} + LETSENCRYPT_HOST: ${BTCPAY_HOST},${BTCPAY_ADDITIONAL_HOSTS} LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL:-} \ No newline at end of file diff --git a/docker-compose-generator/docker-fragments/nginx.yml b/docker-compose-generator/docker-fragments/nginx.yml index e24fd87..02ac015 100644 --- a/docker-compose-generator/docker-fragments/nginx.yml +++ b/docker-compose-generator/docker-fragments/nginx.yml @@ -15,7 +15,7 @@ services: - "nginx_certs:/etc/nginx/certs:ro" nginx-gen: restart: unless-stopped - image: btcpayserver/docker-gen:0.7.5 + image: btcpayserver/docker-gen:0.7.6 container_name: nginx-gen environment: DEFAULT_HOST: ${REVERSEPROXY_DEFAULT_HOST:-none} diff --git a/helpers.sh b/helpers.sh index 8044ed2..f41a959 100755 --- a/helpers.sh +++ b/helpers.sh @@ -70,6 +70,7 @@ touch $BTCPAY_ENV_FILE echo " BTCPAY_PROTOCOL=$BTCPAY_PROTOCOL BTCPAY_HOST=$BTCPAY_HOST +BTCPAY_ADDITIONAL_HOSTS=$BTCPAY_ADDITIONAL_HOSTS BTCPAY_ANNOUNCEABLE_HOST=$BTCPAY_ANNOUNCEABLE_HOST REVERSEPROXY_HTTP_PORT=$REVERSEPROXY_HTTP_PORT REVERSEPROXY_HTTPS_PORT=$REVERSEPROXY_HTTPS_PORT