Browse Source

Adds NGROK_PORT as per issue #3.

Werner Beroux 8 years ago
parent
commit
4f5fdae585
2 changed files with 18 additions and 7 deletions
  1. 1 0
      README.md
  2. 17 7
      entrypoint.sh

+ 1 - 0
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_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_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_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
 ## Feedbacks

+ 17 - 7
entrypoint.sh

@@ -4,6 +4,17 @@ if [ -n "$@" ]; then
   exec "$@"
   exec "$@"
 fi
 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"
 ARGS="ngrok"
 
 
@@ -12,6 +23,7 @@ if [ "$NGROK_PROTOCOL" = "TCP" ]; then
   ARGS="$ARGS tcp"
   ARGS="$ARGS tcp"
 else
 else
   ARGS="$ARGS http"
   ARGS="$ARGS http"
+  NGROK_PORT="${NGROK_PORT:-80}"
 fi
 fi
 
 
 # Set the authorization token.
 # Set the authorization token.
@@ -47,14 +59,12 @@ fi
 
 
 ARGS="$ARGS -log stdout"
 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
 fi
+ARGS="$ARGS `echo $NGROK_PORT | sed 's|^tcp://||'`"
 
 
 set -x
 set -x
 exec $ARGS
 exec $ARGS