Merge pull request #3844 from dokku/global-proxy-port-config

Add global fallback for DOKKU_PROXY_PORT and DOKKU_PROXY_SSL_PORT
This commit is contained in:
Jose Diaz-Gonzalez
2020-02-05 15:35:32 -05:00
committed by GitHub
3 changed files with 17 additions and 4 deletions

View File

@@ -116,8 +116,8 @@ The following list config variables have special meaning and can be set in a var
| `DOKKU_DOCKERFILE_PORTS` | dockerfile ports | `dokku config:set` | |
| `DOKKU_DOCKERFILE_START_CMD` | none | `dokku config:set` | |
| `DOKKU_PARALLEL_ARGUMENTS`. | none | `dokku config:set` | Allows passing custom arguments to parallel for `ps:*all` commands |
| `DOKKU_PROXY_PORT` | automatically assigned | `dokku config:set` | |
| `DOKKU_PROXY_SSL_PORT` | automatically assigned | `dokku config:set` | |
| `DOKKU_PROXY_PORT` | automatically assigned | `/etc/environment` <br /> `~dokku/.dokkurc` <br /> `~dokku/.dokkurc/*` <br /> `dokku config:set` | |
| `DOKKU_PROXY_SSL_PORT` | automatically assigned | `/etc/environment` <br /> `~dokku/.dokkurc` <br /> `~dokku/.dokkurc/*` <br /> `dokku config:set` | |
| `DOKKU_PROXY_PORT_MAP` | automatically assigned | `dokku proxy:ports-add` <br /> `dokku proxy:ports-remove`, `dokku proxy:ports-clear` | |
| `DOKKU_SKIP_ALL_CHECKS` | none | `dokku config:set` | |
| `DOKKU_SKIP_CLEANUP` | | `/etc/environment` <br /> `~dokku/.dokkurc` <br /> `~dokku/.dokkurc/*` | When a deploy is triggered, if this is set to a non-empty value, then old docker containers and images will not be removed. |

View File

@@ -96,13 +96,15 @@ configure_nginx_ports() {
dokku_log_info1 "no proxy port set. setting to random open high port"
local PROXY_PORT=$(get_available_port)
else
local PROXY_PORT=80
local PROXY_PORT=$(config_get --global DOKKU_PROXY_PORT)
PROXY_PORT=${PROXY_PORT:=80}
fi
DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$APP" DOKKU_PROXY_PORT="$PROXY_PORT"
fi
if [[ -z "$DOKKU_PROXY_SSL_PORT" ]]; then
if (is_ssl_enabled "$APP"); then
local PROXY_SSL_PORT=443
local PROXY_SSL_PORT=$(config_get --global DOKKU_PROXY_SSL_PORT)
PROXY_SSL_PORT=${PROXY_SSL_PORT:=443}
if [[ -z "$RAW_TCP_PORTS" ]] && [[ "$IS_APP_VHOST_ENABLED" == "false" ]]; then
dokku_log_info1 "no proxy ssl port set. setting to random open high port"
PROXY_SSL_PORT=$(get_available_port)

View File

@@ -141,3 +141,14 @@ teardown() {
echo "status: "$status
assert_success
}
@test "(nginx-vhosts) nginx:build-config (global DOKKU_PROXY_PORT)" {
local GLOBAL_PORT=30999
run /bin/bash -c "dokku config:set --global DOKKU_PROXY_PORT=${GLOBAL_PORT}"
deploy_app
check_urls http://${TEST_APP}.dokku.me:${GLOBAL_PORT}
assert_http_success http://${TEST_APP}.dokku.me:${GLOBAL_PORT}
run /bin/bash -c "dokku config:unset --global DOKKU_PROXY_PORT"
}