diff --git a/tcp-proxy.sh b/tcp-proxy.sh new file mode 100644 index 0000000..2c60a29 --- /dev/null +++ b/tcp-proxy.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +#if [ "$#" -ne 2 ]; then +# echo "usage: $(basename $0) host port" +# exit 1 +#fi + +#HOST="$1" +#PORT="$2" + +DOCKER_HOST_IP=$(route -n | awk '/UG[ \t]/{print $2}'); + +LISTEN_PORT=${LISTEN_PORT:-${PORT}} +HOST=${HOST:-${DOCKER_HOST_IP}} + +echo "relay TCP/IP connections on :${LISTEN_PORT} to ${HOST}:${PORT}" +exec socat TCP-LISTEN:${LISTEN_PORT},fork,reuseaddr TCP:${HOST}:${PORT} \ No newline at end of file