fix: ignore https mappings when no ssl certificate exists

This fixes issues where users may somehow add an https mapping but are missing an ssl certificate, causing nginx to not load properly. We now ignore the mapping and warn users of the misconfiguration.

Closes #5368
This commit is contained in:
Jose Diaz-Gonzalez
2022-10-22 17:47:54 -04:00
parent d0966ce3d4
commit 4ef260f57a
3 changed files with 45 additions and 2 deletions

View File

@@ -116,3 +116,27 @@ teardown() {
echo "status: $status"
assert_output_contains "45s;" 0
}
@test "(nginx-vhosts) nginx:build-config ignore bad https mapping" {
setup_test_tls
run deploy_app "dockerfile-noexpose"
echo "output: $output"
echo "status: $status"
assert_output_contains "Ignoring detected https port mapping without an accompanying ssl certificate" 0
teardown_test_tls
run /bin/bash -c "dokku proxy:report $TEST_APP --proxy-port-map"
echo "output: $output"
echo "status: $status"
assert_output "http:80:5000 https:443:5000"
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_output_contains "Ignoring detected https port mapping without an accompanying ssl certificate" 1
run /bin/bash -c "dokku proxy:report $TEST_APP --proxy-port-map"
echo "output: $output"
echo "status: $status"
assert_output "http:80:5000 https:443:5000"
}

View File

@@ -366,6 +366,11 @@ setup_test_tls() {
sudo chown -R dokku:dokku "${TLS}/.."
}
teardown_test_tls() {
local TLS="/home/dokku/$TEST_APP/tls"
rm -rf "$TLS"
}
custom_ssl_nginx_template() {
local APP="$1"
local APP_REPO_DIR="$2"