Merge pull request #5493 from dokku/5410-fix-ssl-detection
Correct issue with detection of non-https port mapping as https port mapping
This commit is contained in:
@@ -72,6 +72,16 @@ trigger-caddy-vhosts-docker-args-process-deploy() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
letsencrypt_email="$(fn-caddy-letsencrypt-email)"
|
||||||
|
if [[ -n "$letsencrypt_email" ]] && [[ -z "$proxy_container_https_port" ]]; then
|
||||||
|
proxy_container_https_port_candidate="$proxy_container_http_port_candidate"
|
||||||
|
proxy_host_https_port_candidate="$proxy_host_http_port_candidate"
|
||||||
|
if [[ -n "$proxy_container_http_port" ]]; then
|
||||||
|
proxy_container_https_port_candidate="$proxy_container_http_port"
|
||||||
|
proxy_host_http_port_candidate=443
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
app_domains="$(plugn trigger domains-list "$APP")"
|
app_domains="$(plugn trigger domains-list "$APP")"
|
||||||
if [[ -n "$app_domains" ]]; then
|
if [[ -n "$app_domains" ]]; then
|
||||||
caddy_domains="$(echo "$app_domains" | xargs)"
|
caddy_domains="$(echo "$app_domains" | xargs)"
|
||||||
@@ -98,7 +108,6 @@ trigger-caddy-vhosts-docker-args-process-deploy() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
letsencrypt_email="$(fn-caddy-letsencrypt-email)"
|
|
||||||
scheme="http"
|
scheme="http"
|
||||||
if [[ -n "$letsencrypt_email" ]] && [[ "$has_443_mapping" == "true" ]]; then
|
if [[ -n "$letsencrypt_email" ]] && [[ "$has_443_mapping" == "true" ]]; then
|
||||||
output="--label 'caddy=${caddy_domains}'"
|
output="--label 'caddy=${caddy_domains}'"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ trigger-traefik-vhosts-docker-args-process-deploy() {
|
|||||||
declare desc="nginx-vhosts core-post-deploy plugin trigger"
|
declare desc="nginx-vhosts core-post-deploy plugin trigger"
|
||||||
declare trigger="docker-args-process-deploy"
|
declare trigger="docker-args-process-deploy"
|
||||||
declare APP="$1" IMAGE_SOURCE_TYPE="$2" IMAGE_TAG="$3" PROC_TYPE="$4" CONTAINER_INDEX="$5"
|
declare APP="$1" IMAGE_SOURCE_TYPE="$2" IMAGE_TAG="$3" PROC_TYPE="$4" CONTAINER_INDEX="$5"
|
||||||
local app_domains is_app_listening output proxy_container_port proxy_host_port port_map proxy_port_map priority proxy_scheme proxy_schemes traefik_domains
|
local app_domains is_app_listening letsencrypt_email output proxy_container_port proxy_host_port port_map proxy_port_map priority proxy_scheme proxy_schemes traefik_domains
|
||||||
local proxy_container_http_port proxy_container_http_port_candidate proxy_host_http_port_candidate
|
local proxy_container_http_port proxy_container_http_port_candidate proxy_host_http_port_candidate
|
||||||
local proxy_container_https_port proxy_container_https_port_candidate proxy_host_https_port_candidate
|
local proxy_container_https_port proxy_container_https_port_candidate proxy_host_https_port_candidate
|
||||||
local app_urls_path="$DOKKU_ROOT/$APP/URLS"
|
local app_urls_path="$DOKKU_ROOT/$APP/URLS"
|
||||||
@@ -72,6 +72,16 @@ trigger-traefik-vhosts-docker-args-process-deploy() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
letsencrypt_email="$(fn-traefik-letsencrypt-email)"
|
||||||
|
if [[ -n "$letsencrypt_email" ]] && [[ -z "$proxy_container_https_port" ]]; then
|
||||||
|
proxy_container_https_port_candidate="$proxy_container_http_port_candidate"
|
||||||
|
proxy_host_https_port_candidate="$proxy_host_http_port_candidate"
|
||||||
|
if [[ -n "$proxy_container_http_port" ]]; then
|
||||||
|
proxy_container_https_port_candidate="$proxy_container_http_port"
|
||||||
|
proxy_host_http_port_candidate=443
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# add the labels for traefik here
|
# add the labels for traefik here
|
||||||
# any `http:80` port mapping is treated as a `http` traefik entrypoint
|
# any `http:80` port mapping is treated as a `http` traefik entrypoint
|
||||||
# any `https:443` port mapping is treated as a `https` traefik entrypoint
|
# any `https:443` port mapping is treated as a `https` traefik entrypoint
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ load test_helper
|
|||||||
setup() {
|
setup() {
|
||||||
global_setup
|
global_setup
|
||||||
dokku nginx:stop
|
dokku nginx:stop
|
||||||
|
dokku caddy:set --global letsencrypt-server https://acme-staging-v02.api.letsencrypt.org/directory
|
||||||
|
dokku caddy:set --global letsencrypt-email
|
||||||
dokku caddy:start
|
dokku caddy:start
|
||||||
create_app
|
create_app
|
||||||
}
|
}
|
||||||
@@ -81,3 +83,62 @@ teardown() {
|
|||||||
assert_success
|
assert_success
|
||||||
assert_output "python/http.server"
|
assert_output "python/http.server"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "(caddy) ssl" {
|
||||||
|
run /bin/bash -c "dokku builder-herokuish:set $TEST_APP allowed true"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku proxy:set $TEST_APP caddy"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run deploy_app
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "docker inspect $TEST_APP.web.1 --format '{{ index .Config.Labels \"caddy\" }}'"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output "$TEST_APP.dokku.me:80"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku caddy:set --global letsencrypt-email test@example.com"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku caddy:stop"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku caddy:start"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:rebuild $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:inspect $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "docker inspect $TEST_APP.web.1 --format '{{ index .Config.Labels \"caddy\" }}'"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output "$TEST_APP.dokku.me"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku proxy:report $TEST_APP --proxy-port-map"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output "http:80:5000"
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ load test_helper
|
|||||||
setup() {
|
setup() {
|
||||||
global_setup
|
global_setup
|
||||||
dokku nginx:stop
|
dokku nginx:stop
|
||||||
|
dokku traefik:set --global letsencrypt-server https://acme-staging-v02.api.letsencrypt.org/directory
|
||||||
|
dokku traefik:set --global letsencrypt-email
|
||||||
dokku traefik:start
|
dokku traefik:start
|
||||||
create_app
|
create_app
|
||||||
}
|
}
|
||||||
@@ -103,3 +105,79 @@ teardown() {
|
|||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_output "5000"
|
assert_output "5000"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "(traefik) ssl" {
|
||||||
|
run /bin/bash -c "dokku builder-herokuish:set $TEST_APP allowed true"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku traefik:set $TEST_APP priority 12345"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku proxy:set $TEST_APP traefik"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run deploy_app
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "docker inspect $TEST_APP.web.1 --format '{{ index .Config.Labels \"traefik.http.services.$TEST_APP-web-http-12345.loadbalancer.server.port\" }}'"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output "5000"
|
||||||
|
|
||||||
|
run /bin/bash -c "docker inspect $TEST_APP.web.1 --format '{{ index .Config.Labels \"traefik.http.services.$TEST_APP-web-https-12345.loadbalancer.server.port\" }}'"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output ""
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku traefik:set --global letsencrypt-email test@example.com"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku traefik:stop"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku traefik:start"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:rebuild $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:inspect $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "docker inspect $TEST_APP.web.1 --format '{{ index .Config.Labels \"traefik.http.services.$TEST_APP-web-http-12345.loadbalancer.server.port\" }}'"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output "5000"
|
||||||
|
|
||||||
|
run /bin/bash -c "docker inspect $TEST_APP.web.1 --format '{{ index .Config.Labels \"traefik.http.services.$TEST_APP-web-https-12345.loadbalancer.server.port\" }}'"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output "5000"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku proxy:report $TEST_APP --proxy-port-map"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output "http:80:5000"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user