commit 40347bbf5a4c871b7103d9ce22c0d5408b7a738d Author: ge Date: Tue Dec 27 21:57:50 2022 +0300 init diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ee4fef4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM alpine:3.17.0 +RUN apk add --no-cache curl libqrencode +RUN tag="$(curl -sSo /dev/null -w '%{redirect_url}' \ + https://github.com/Snawoot/dumbproxy/releases/latest | \ + cut -d '/' -f 8)"; \ + curl -sSL -o /usr/bin/dumbproxy \ + https://github.com/Snawoot/dumbproxy/releases/download/$tag/dumbproxy.linux-amd64 +COPY entrypoint.sh /usr/local/bin/docker-entrypoint.sh +RUN chmod +x /usr/bin/dumbproxy /usr/local/bin/docker-entrypoint.sh + +ENV ADDRESS="${ADDRESS:-:8080}" +ENV AUTH= +ENV USERNAME= +ENV PASSWORD= +ENV HIDDEN_DOMAIN= +ENV OPTIONS= + +USER nobody +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] +EXPOSE 8080 +STOPSIGNAL SIGINT +CMD ["/usr/bin/dumbproxy"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..ec41c6c --- /dev/null +++ b/README.md @@ -0,0 +1,35 @@ +# HTTP(S) proxy dumbproxy image + +Motivation — the [original dumbproxy](https://hub.docker.com/r/yarmak/dumbproxy) +image [doesn't have](https://github.com/Snawoot/dumbproxy/blob/master/Dockerfile) +any configuration options. + +## Build + +```shell +docker build -t nxhs/dumbproxy:latest -t nxhs/dumbproxy:1.7.0 . +``` + +## Run + +```shell +docker run -d \ + --restart always \ + --security-opt no-new-privileges \ + -p 8080:8080 \ + -e USERNAME=myuser \ + -e PASSWORD=secure_password \ + --name dumbproxy \ + nxhs/dumbproxy:latest +``` + +## Environment + +| Variable | Description | +| ------------- | --------------------------------------------------------------------------------- | +| `ADDRESS` | Argument for `-bind-address`. HTTP proxy listen address (default ":8080") | +| `AUTH` | Argument for [-auth option](https://github.com/Snawoot/dumbproxy#authentication) | +| `USERNAME` | Username for `-auth` option with `static` scheme | +| `PASSWORD` | Password for `-auth` option with `static` scheme | +| `HIDDEN_DOMAIN` | See [Authentication](https://github.com/Snawoot/dumbproxy#authentication) | +| `OPTIONS` | Any [options](https://github.com/Snawoot/dumbproxy#synopsis) what you want | diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..18be341 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +set -o errexit + +if [ "$1" = "/usr/bin/dumbproxy" ]; then + if [ -n "$AUTH" ]; then + ARGS="-bind-address $ADDRESS -auth $AUTH $OPTIONS" + elif [ -n "$USERNAME" ] && [ -n "$PASSWORD" ]; then + if [ -n "$HIDDEN_DOMAIN" ]; then + AUTH="static://?username=$USERNAME&password=$PASSWORD&hidden_domain=$HIDDEN_DOMAIN" + else + AUTH="static://?username=$USERNAME&password=$PASSWORD" + fi + ARGS="-bind-address $ADDRESS -auth $AUTH $OPTIONS" + else + ARGS="-bind-address $ADDRESS $OPTIONS" + fi +fi + +# shellcheck disable=SC2086 +exec "$@" $ARGS