This commit is contained in:
ge 2022-12-27 21:57:50 +03:00
commit 40347bbf5a
3 changed files with 78 additions and 0 deletions

22
Dockerfile Normal file
View File

@ -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"]

35
README.md Normal file
View File

@ -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 |

21
entrypoint.sh Normal file
View File

@ -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