-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add password protection support to docker image
- Loading branch information
Showing
2 changed files
with
22 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
FROM debian:stretch | ||
|
||
ADD ./init.sh /init | ||
RUN chmod +x /init && apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/* | ||
ADD ./init.sh /init.sh | ||
RUN chmod +x /init.sh && apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/* | ||
|
||
ADD build/trafficmirror /trafficmirror | ||
|
||
CMD ["/init"] | ||
CMD ["/init.sh"] | ||
|
||
EXPOSE 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
#!/bin/sh | ||
|
||
LISTEN_PORT=${LISTEN_PORT:-7077} | ||
MAIN=${MAIN:-localhost:8888} | ||
EXTRA_PARAMS=$1 | ||
# Takes these environment variables: | ||
# | ||
# LISTEN_PORT: port to listen on (defaults to 7077) | ||
# MAIN: reverse proxy to this address (defaults to localhost:8888) | ||
# USERNAME & PASSWORD: if USERNAME is set protect targets endpoint with basic auth (default to empty) | ||
|
||
echo /trafficmirror /trafficmirror -listen ":${LISTEN_PORT}" -main=${MAIN} $EXTRA_PARAMS | ||
/trafficmirror -listen ":${LISTEN_PORT}" -main=${MAIN} $EXTRA_PARAMS | ||
listen_port=${LISTEN_PORT:-7077} | ||
main=${MAIN:-localhost:8888} | ||
extra_params=$1 | ||
|
||
if [ ! -z "${USERNAME}" ] | ||
then | ||
printf "${USERNAME}:${PASSWORD}" > /password.file | ||
extra_params="${extra_params} -password /password.file" | ||
fi | ||
|
||
cmd="/trafficmirror -listen ":${listen_port}" -main=${main} $extra_params" | ||
|
||
echo "$cmd" | ||
eval "$cmd" |