From df9ec0f849dac4281e1f7fce51473de2739fd3a9 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Fri, 25 Jan 2019 16:38:54 +0100 Subject: [PATCH] fix: [gitea,apache] correctly set ``https`` clone url when using ``https``. --- apache/lib/common | 7 +++++++ apache/test/vhost_files | 16 ++++++++++++++-- gitea/hooks/web_proxy-relation-joined | 7 ++++--- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/apache/lib/common b/apache/lib/common index d884cb9f..8ed0a294 100644 --- a/apache/lib/common +++ b/apache/lib/common @@ -71,7 +71,14 @@ $(if [ "$custom_rules" ]; then echo "- |"$'\n'"$(echo "$custom_rules" | prefix " ")" fi)" fi + relation-set protocol https + else + ## Both services are available and different, don't do anything then ? + #relation-set protocol https + : fi + else + relation-set protocol http fi vhost_statement=$(apache_vhost_statement "$PROTOCOLS") || return 1 echo "$vhost_statement"| file_put "$APACHE_CONFIG_LOCATION/$prefix$DOMAIN.conf" || return 1 diff --git a/apache/test/vhost_files b/apache/test/vhost_files index dadeb0fa..2b4d5fef 100644 --- a/apache/test/vhost_files +++ b/apache/test/vhost_files @@ -94,7 +94,10 @@ export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE' DOMAIN=www.example.com DOCKER_SITE_PATH=/var/www/\$DOMAIN apache_vhost_create" -noerror +is errlvl 0 +is err part "\ +relation-set protocol: + | http" is out reg '^file_put \$SERVICE_CONFIGSTORE/.*/www.example.com.conf' try " @@ -107,6 +110,9 @@ ssl: true apache_vhost_create" is errlvl 0 is err part "## Auto-redirection from http to https" +is err part "\ +relation-set protocol: + | https" is out reg '^file_put \$SERVICE_CONFIGSTORE/.*/www.example.com.conf' @@ -127,6 +133,9 @@ ssl: apache_vhost_create" is errlvl 0 is err part "## Auto-redirection from http to https" +is err part "\ +relation-set protocol: + | https" is out part 'file_put $CONFIGSTORE/$BASE_SERVICE_NAME/etc/ssl/certs/www.example.com.pem | c' is out part 'file_put $CONFIGSTORE/$BASE_SERVICE_NAME/etc/ssl/private/www.example.com.key @@ -150,7 +159,10 @@ creds: toto: xxx ' apache_vhost_create" -noerror +is errlvl 0 +is err part "\ +relation-set protocol: + | http" is out reg "htpasswd -bc '/etc/apache2/sites-enabled/www.example.com.passwd' 'toto' 'xxx'" is out reg 'docker run -i --entrypoint /bin/bash .* docker/apache' diff --git a/gitea/hooks/web_proxy-relation-joined b/gitea/hooks/web_proxy-relation-joined index 6fa2f4c8..aa0272aa 100755 --- a/gitea/hooks/web_proxy-relation-joined +++ b/gitea/hooks/web_proxy-relation-joined @@ -5,7 +5,8 @@ set -e . lib/common DOMAIN=$(relation-get domain) || exit 1 +PROTO=$(relation-get protocol) || true +PROTO=${PROTO:-https} -ini set server ROOT_URL "http://$DOMAIN/" -ini set server SSH_DOMAIN "$DOMAIN" - +ini set server ROOT_URL "$PROTO://$DOMAIN/" +ini set server SSH_DOMAIN "$DOMAIN" \ No newline at end of file