diff --git a/docs/configuration/misc-options.md b/docs/configuration/misc-options.md index fb68e2ea..068ee997 100644 --- a/docs/configuration/misc-options.md +++ b/docs/configuration/misc-options.md @@ -107,11 +107,7 @@ such as: ## HTTP Proxy -You may configure the use of an HTTP/HTTPS proxy by passing the proxy's URL via the `PROXY` -environment variable. In [the example compose file](https://github.com/itzg/docker-minecraft-server/blob/master/examples/docker-compose-proxied.yml) it references -a companion squid proxy by setting the equivalent of - - -e PROXY=proxy:3128 +You may configure the use of an HTTP/HTTPS proxy by passing the proxy's "host:port" via the environment variable `PROXY`. In [the example compose file](https://github.com/itzg/docker-minecraft-server/blob/master/examples/docker-compose-proxied.yml) it references a Squid proxy. The host and port can be separately passed via the environment variables `PROXY_HOST` and `PROXY_PORT`. A `|` delimited list of hosts to exclude from proxying can be passed via `PROXY_NON_PROXY_HOSTS`. ## Using "noconsole" option diff --git a/scripts/start-configuration b/scripts/start-configuration index 031614b5..490f43b7 100755 --- a/scripts/start-configuration +++ b/scripts/start-configuration @@ -101,14 +101,28 @@ if isTrue "${ENABLE_AUTOPAUSE}" && isTrue "${ENABLE_AUTOSTOP}"; then exit 1 fi +proxyArgs=() if [[ $PROXY ]]; then export http_proxy="$PROXY" export https_proxy="$PROXY" - export JAVA_TOOL_OPTIONS+="-Djava.net.useSystemProxies=true" - log "INFO: Giving proxy time to startup..." - sleep 5 + # only calculate fallback + : "${PROXY_HOST=$(echo "$PROXY" | cut -d : -f 1)}" + : "${PROXY_PORT=$(echo "$PROXY" | cut -d : -f 2)}" + proxyArgs+=(-Djava.net.useSystemProxies=true) fi +# https://docs.oracle.com/javase/7/docs/api/java/net/doc-files/net-properties.html +proxyArgs=() +function addToProxyArgs() { + if [[ $2 ]]; then + proxyArgs+=("-D$1=$2") + fi +} +addToProxyArgs http.proxyHost "${PROXY_HOST:-}" +addToProxyArgs http.proxyPort "${PROXY_PORT:-}" +addToProxyArgs http.nonProxyHosts "${PROXY_NON_PROXY_HOSTS:-}" +export JAVA_TOOL_OPTIONS+=" ${proxyArgs[*]}" + function fixJavaPath() { # Some Docker management UIs grab all the image declared variables and present them for configuration. # When upgrading images across Java versions, that creates a mismatch in PATH's expected by base image.