From 4f5fdae585c3a36eac5c5c3595c83ceb1a73ba09 Mon Sep 17 00:00:00 2001 From: Werner Beroux Date: Fri, 1 Jul 2016 14:20:45 +0000 Subject: [PATCH] Adds NGROK_PORT as per issue #3. --- README.md | 1 + entrypoint.sh | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a474d25..953eb17 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ Additionally, you can specify one of several environment variable (via `-e`) to * `NGROK_USERNAME` - Username to use for HTTP authentication on the tunnel. You must also specify an authentication token. * `NGROK_PASSWORD` - Password to use for HTTP authentication on the tunnel. You must also specify an authentication token. * `NGROK_PROTOCOL` - Can either be `HTTP` or `TCP`, and it defaults to `HTTP` if not specified. If set to `TCP`, Ngrok will allocate a port instead of a subdomain and proxy TCP requests directly to your application. + * `NGROK_PORT` - Port to expose (defaults to `80` for `HTTP` protocol). ## Feedbacks diff --git a/entrypoint.sh b/entrypoint.sh index 7399554..a2897f9 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,6 +4,17 @@ if [ -n "$@" ]; then exec "$@" fi +# Legacy compatible: +if [ -z "$NGROK_PORT" ]; then + if [ -n "$HTTPS_PORT" ]; then + NGROK_PORT="$HTTPS_PORT" + elif [ -n "$HTTPS_PORT" ]; then + NGROK_PORT="$HTTP_PORT" + elif [ -n "$APP_PORT" ]; then + NGROK_PORT="$APP_PORT" + fi +fi + ARGS="ngrok" @@ -12,6 +23,7 @@ if [ "$NGROK_PROTOCOL" = "TCP" ]; then ARGS="$ARGS tcp" else ARGS="$ARGS http" + NGROK_PORT="${NGROK_PORT:-80}" fi # Set the authorization token. @@ -47,14 +59,12 @@ fi ARGS="$ARGS -log stdout" -# Set the point. -if [ -n "$HTTPS_PORT" ]; then - ARGS="$ARGS `echo $HTTPS_PORT | sed 's|^tcp://||'`" -elif [ -n "$HTTP_PORT" ]; then - ARGS="$ARGS `echo $HTTP_PORT | sed 's|^tcp://||'`" -elif [ -n "$APP_PORT" ]; then - ARGS="$ARGS `echo $APP_PORT | sed 's|^tcp://||'`" +# Set the port. +if [ -z "$NGROK_PORT" ]; then + echo "You must specify a NGROK_PORT to expose." + exit 1 fi +ARGS="$ARGS `echo $NGROK_PORT | sed 's|^tcp://||'`" set -x exec $ARGS