From 84a64d885a0d9d83b438cf1736009d823c8e132d Mon Sep 17 00:00:00 2001
From: Maik Hummel <6891349+beevelop@users.noreply.github.com>
Date: Thu, 3 Dec 2026 13:04:53 +0100
Subject: [PATCH 1/5] Winter clean: harden nginx auth proxy and image CI
---
.dockerignore | 4 ++
.github/scripts/smoke.sh | 79 ++++++++++++++++++++++++++
.github/workflows/docker.yml | 107 ++++++++++++++++++++++-------------
.gitignore | 1 +
Dockerfile | 20 +++----
README.md | 85 +++++++++-------------------
auth.conf | 15 ++---
auth.htpasswd | 1 -
docker-stack.yml | 43 +++++---------
launch.sh | 59 +++++++++++++++++--
10 files changed, 262 insertions(+), 152 deletions(-)
create mode 100644 .dockerignore
create mode 100644 .github/scripts/smoke.sh
create mode 100644 .gitignore
delete mode 100644 auth.htpasswd
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..42d2a6d
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,4 @@
+*
+!Dockerfile
+!auth.conf
+!launch.sh
diff --git a/.github/scripts/smoke.sh b/.github/scripts/smoke.sh
new file mode 100644
index 0000000..63f709a
--- /dev/null
+++ b/.github/scripts/smoke.sh
@@ -0,0 +1,79 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+image=$1
+scratch=$(mktemp -d)
+network="nginx-auth-smoke-${scratch##*.}"
+backend="$network-backend"
+proxy="$network-proxy"
+
+cleanup() {
+ local status=$?
+ if (( status != 0 )); then
+ docker logs "$proxy" 2>/dev/null || true
+ docker logs "$backend" 2>/dev/null || true
+ fi
+ docker rm -f "$proxy" "$backend" >/dev/null 2>&1 || true
+ docker network rm "$network" >/dev/null 2>&1 || true
+ rm -rf "$scratch"
+}
+trap cleanup EXIT
+
+cat > "$scratch/backend.conf" <<'NGINX'
+server {
+ listen 8081;
+ location / {
+ return 200 "auth=$http_authorization uri=$request_uri";
+ }
+}
+NGINX
+record="smoke:$(openssl passwd -apr1 smoke-password)"
+# bcrypt fixture for smoke-password, matching the README’s htpasswd -B example.
+printf '%s\n' 'smoke:$2y$05$ABCDEFGHIJKLMNOPQRSTUOAkTpB.z20KXyNR5j2rJdcYl4myGhdKu' > "$scratch/users.htpasswd"
+
+# Without credentials, require the specific configuration error.
+if result=$(docker run --rm "$image" 2>&1); then
+ echo 'The proxy started without credentials.' >&2
+ exit 1
+fi
+[[ "$result" == *'Set HTPASSWD or HTPASSWD_FILE'* ]]
+
+# Reject a value that would terminate the proxy_pass directive.
+if result=$(docker run --rm -e FORWARD_HOST='backend;#' -e HTPASSWD="$record" "$image" 2>&1); then
+ echo 'The proxy accepted an invalid upstream hostname.' >&2
+ exit 1
+fi
+[[ "$result" == *'FORWARD_HOST must be'* ]]
+
+docker network create "$network" >/dev/null
+docker run -d --name "$backend" --network "$network" --network-alias backend \
+ --mount "type=bind,src=$scratch/backend.conf,dst=/etc/nginx/conf.d/default.conf,readonly" \
+ --entrypoint nginx "$image" -g 'daemon off;' >/dev/null
+
+for credential_mode in file inline; do
+ if [[ "$credential_mode" == file ]]; then
+ credential_args=(
+ -e HTPASSWD_FILE=/run/secrets/proxy_users
+ --mount "type=bind,src=$scratch/users.htpasswd,dst=/run/secrets/proxy_users,readonly"
+ )
+ else
+ credential_args=(-e HTPASSWD="$record")
+ fi
+ docker run -d --name "$proxy" --network "$network" -p 127.0.0.1::80 \
+ -e FORWARD_HOST=backend -e FORWARD_PORT=8081 "${credential_args[@]}" "$image" >/dev/null
+ endpoint="http://$(docker port "$proxy" 80/tcp)/probe?one=two"
+
+ for _ in {1..20}; do
+ if status=$(curl --noproxy '*' -s -o /dev/null -w '%{http_code}' --max-time 2 "$endpoint"); then
+ break
+ fi
+ sleep 1
+ done
+ [[ "$status" == 401 ]]
+ [[ $(curl --noproxy '*' -s -o /dev/null -w '%{http_code}' --max-time 3 \
+ -u smoke:wrong-password "$endpoint") == 401 ]]
+ [[ $(curl --noproxy '*' -fsS --max-time 3 -u smoke:smoke-password "$endpoint") \
+ == 'auth= uri=/probe?one=two' ]]
+ docker rm -f "$proxy" >/dev/null
+ printf 'Proxy passed with %s credentials.\n' "$credential_mode"
+done
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 515a7f8..3671b81 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -2,63 +2,90 @@ name: Docker Image
on:
schedule:
- - cron: "0 10 * * *" # everyday at 10am
+ - cron: '17 10 * * 2'
workflow_dispatch:
pull_request:
- branches: ["**"]
+ branches: [latest]
push:
- branches: ["**"]
- tags: ["v*.*.*"]
+ branches: [latest]
+ tags: ['v*.*.*']
+
+permissions:
+ contents: read
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
- platforms: linux/amd64,linux/arm64/v8,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
+ IMAGE: beevelop/nginx-basic-auth
+ PUBLISH: >-
+ ${{ github.repository == 'beevelop/docker-nginx-basic-auth' &&
+ github.actor != 'dependabot[bot]' &&
+ ((github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) ||
+ (github.event_name != 'pull_request' && github.ref == 'refs/heads/latest')) }}
jobs:
main:
- runs-on: ubuntu-22.04
- timeout-minutes: 10
+ runs-on: ubuntu-24.04
+ timeout-minutes: 20
steps:
- - name: Check out the repo
- uses: actions/checkout@v7
- with:
- ref: ${{ github.head_ref || github.ref }}
- - name: Set imageName based on the repository name
- id: step_one
- run: |
- imageName="${GITHUB_REPOSITORY/docker-/}"
- echo $imageName
- echo "imageName=$imageName" >> $GITHUB_ENV
- - name: Docker meta
- id: docker_meta
- uses: docker/metadata-action@v6
+ - name: Check out the repository
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
- images: ${{ env.imageName }}
- - name: Set up QEMU
- uses: docker/setup-qemu-action@v4
+ persist-credentials: false
+
- name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v4
- - name: Login to DockerHub
- if: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
- uses: docker/login-action@v4.8.0
+ uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
+
+ - name: Check Dockerfile
+ run: docker buildx build --check .
+
+ - name: Build smoke-test image
+ uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
+ with:
+ context: .
+ platforms: linux/amd64
+ load: true
+ tags: nginx-basic-auth:smoke
+
+ - name: Test HTTP authentication and forwarding
+ run: bash .github/scripts/smoke.sh nginx-basic-auth:smoke
+
+ - name: Generate image tags and labels
+ if: env.PUBLISH == 'true'
+ id: meta
+ uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
+ with:
+ images: ${{ env.IMAGE }}
+
+ - name: Log in to Docker Hub
+ if: env.PUBLISH == 'true'
+ uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- - name: Build and push
- id: docker_build
- uses: docker/build-push-action@v7
+ # The Dockerfile only copies files into the base image, so no emulation is needed.
+ - name: Publish multi-platform image
+ if: env.PUBLISH == 'true'
+ id: publish
+ uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
- platforms: ${{ env.platforms }}
- push: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
- pull: true
- tags: ${{ steps.docker_meta.outputs.tags }}
- labels: ${{ steps.docker_meta.outputs.labels }}
- - name: Docker Scout
- id: docker-scout-cves
- if: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
- uses: docker/scout-action@v1.29.0
+ context: .
+ platforms: linux/amd64,linux/arm64/v8,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
+ push: true
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
+ provenance: mode=min
+ sbom: true
+
+ - name: Report critical and high CVEs with Docker Scout
+ if: env.PUBLISH == 'true'
+ continue-on-error: true
+ uses: docker/scout-action@b265cd48f8a1451d2680815b3e8dc4ed65ee16e7 # v1.30.0
with:
command: cves
- image: ${{ env.imageName }}:${{ steps.docker_meta.outputs.version }}
+ image: ${{ env.IMAGE }}@${{ steps.publish.outputs.digest }}
only-severities: critical,high
exit-code: false
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..621b261
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/users.htpasswd
diff --git a/Dockerfile b/Dockerfile
index f06887e..f9bdd0e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,16 +1,10 @@
-FROM nginx:alpine
+FROM nginx:1.30.8-alpine-slim@sha256:e9eaa7298465eab06d618c51556fdcf3fb5061f9ff40bd28ee898fbd7ee7f900
-ENV HTPASSWD='foo:$apr1$odHl5EJN$KbxMfo86Qdve2FH4owePn.' \
- FORWARD_PORT=80 \
- FORWARD_HOST=web
+ENV FORWARD_HOST=web \
+ FORWARD_PORT=80
-WORKDIR /opt
+COPY auth.conf /opt/nginx-basic-auth/auth.conf.template
+COPY --chmod=0755 launch.sh /usr/local/bin/launch.sh
-RUN apk add --no-cache gettext
-
-COPY auth.conf auth.htpasswd launch.sh ./
-
-# make sure root login is disabled
-RUN sed -i -e 's/^root::/root:!:/' /etc/shadow
-
-CMD ["./launch.sh"]
+ENTRYPOINT ["/usr/local/bin/launch.sh"]
+CMD ["nginx", "-g", "daemon off;"]
diff --git a/README.md b/README.md
index 005b442..ec56d28 100644
--- a/README.md
+++ b/README.md
@@ -1,71 +1,50 @@
-
-
-
-
-
-[](https://github.com/beevelop/docker-nginx-basic-auth/releases)
-
-
-[](https://beevelop.com)
+[](https://github.com/beevelop/docker-nginx-basic-auth/actions/workflows/docker.yml)
+[](https://hub.docker.com/r/beevelop/nginx-basic-auth)
+[](https://github.com/beevelop/docker-nginx-basic-auth/releases)
-# Docker Nginx Basic Auth - Simple Authentication Proxy
+# Nginx Basic Auth proxy
-> Lightweight nginx reverse proxy with HTTP basic authentication for securing Docker containers and web applications.
+Protect an HTTP service behind nginx with HTTP Basic authentication. This image uses nginx 1.30.8 stable on Alpine and listens on container port 80. The nginx master initializes the configuration and workers run as the `nginx` user.
## Quickstart
-```bash
-docker run -d --name web dockercloud/hello-world
-docker run -d -p 80:80 --link web:web --name auth beevelop/nginx-basic-auth
-```
-
-Try accessing and logging in with username `foo` and password `bar`.
+Use Docker Compose and an `htpasswd` file. On Debian and Ubuntu, install `apache2-utils` if `htpasswd` is missing.
-## Advanced
-
-```bash
-docker run -d \
- -e HTPASSWD='foo:$apr1$odHl5EJN$KbxMfo86Qdve2FH4owePn.' \
- -e FORWARD_PORT=1337 \
- --link web:web -p 8080:80 \
- --name auth \
- beevelop/nginx-basic-auth
+```sh
+git clone https://github.com/beevelop/docker-nginx-basic-auth.git
+cd docker-nginx-basic-auth
+(umask 077; htpasswd -cB users.htpasswd alice)
+docker compose -f docker-stack.yml up -d
+curl -u alice http://127.0.0.1:8080/
```
-> Use single quotes to prevent unwanted interpretation of `$` signs!
+Run `htpasswd -B users.htpasswd another-user` to add users. Omit `-c` when updating an existing file. The example proxies a welcome page on the Compose network, where only the proxy is exposed to the host. Change the `web` service to your upstream and set `FORWARD_PORT` if it listens on another port. Run `docker compose -f docker-stack.yml down` to stop the example. This example binds to loopback in Compose. Swarm ingress publishes on all host interfaces even when a loopback address is specified.
## Configuration
-- `HTPASSWD` (default: `foo:$apr1$odHl5EJN$KbxMfo86Qdve2FH4owePn.`): Will be written to the .htpasswd file on launch (non-persistent)
-- `FORWARD_PORT` (default: `80`): Port of the **source** container that should be forwarded
-- `FORWARD_HOST` (default: `web`): Hostname of the **source** container that should be forwarded
- > The container does not need any volumes to be mounted! Nonetheless you will find all interesting files at `/etc/nginx/*`.
-
-## Multiple Users
-
-Multiple Users are possible by separating the users by newline. To pass the newlines properly you need to use Shell Quoting (like `$'foo\nbar'`):
-
-```
-docker run -d --link web:web --name auth \
- -e HTPASSWD=$'foo:$apr1$odHl5EJN$KbxMfo86Qdve2FH4owePn.\ntest:$apr1$LKkW8P4Y$P1X/r2YyaexhVL1LzZAQm.' \
- beevelop/nginx-basic-auth
-```
+| Variable | Default | Description |
+| --- | --- | --- |
+| `HTPASSWD_FILE` | | Path inside the container to a readable `htpasswd` file. Prefer a Compose secret or a read-only mount. |
+| `HTPASSWD` | | Inline `htpasswd` records separated by newlines. Single-quote literal records to protect `$` characters in hashes. |
+| `FORWARD_HOST` | `web` | Upstream hostname or IPv4 address, resolvable inside the container. |
+| `FORWARD_PORT` | `80` | Upstream HTTP port. |
-results in 2 users (`foo:bar` and `test:test`).
+Supply exactly one credential option. Upgrading from an older image requires configuring your own credentials if the deployment used the previous `foo` / `bar` default. Existing `HTPASSWD` records continue to work. Recreate the proxy to apply credential changes or resolve a replaced upstream hostname again.
-## Troubleshooting
+For plain `docker run`, attach both containers to the same user-defined network and use the upstream container name as `FORWARD_HOST`. Mount the credentials file with `--mount type=bind,src="$(pwd)/users.htpasswd",dst=/run/secrets/proxy_users,readonly` and set `-e HTPASSWD_FILE=/run/secrets/proxy_users`. For remote clients, terminate HTTPS at a trusted gateway in front of this proxy. The proxy consumes the Basic credentials and omits the `Authorization` header when forwarding upstream.
-**Error: `nginx: [emerg] host not found in upstream "web"`**
-- Ensure you link the container as `web` using `--link foobar:web`
+## Build and test
-## Limitations
+```sh
+docker build -t nginx-basic-auth:local .
+bash .github/scripts/smoke.sh nginx-basic-auth:local
+```
-- SSL/HTTPS is not currently supported
-- For SSL requirements, consider using `jwilder/nginx-proxy` as a central gateway with `VIRTUAL_HOST` environment variable
+Pull requests build and exercise the proxy without registry credentials. GitHub Actions publishes from `latest` and `v*.*.*` release tags, with a weekly scheduled refresh of `nightly` and `latest`. Prefer a release tag or image digest when deploying.
---
-# All Docker Images
+## Related Beevelop images
| Badge | Pulls | Build Status | Release Date | Release |
| --- | --- | --- | --- | --- |
@@ -76,11 +55,3 @@ results in 2 users (`foo:bar` and `test:test`).
| [](https://github.com/beevelop/docker-cordova) |  |  |  |  |
| [](https://github.com/beevelop/docker-ionic) |  |  |  |  |
| [](https://github.com/beevelop/docker-nginx-basic-auth) |  |  |  |  |
-
----
-
-
-
-### Use tags where possible, because
-
-
diff --git a/auth.conf b/auth.conf
index aaebd2e..01095e5 100644
--- a/auth.conf
+++ b/auth.conf
@@ -1,11 +1,12 @@
server {
- listen 80 default_server;
+ listen 80 default_server;
- location / {
- auth_basic "Restricted";
- auth_basic_user_file auth.htpasswd;
+ location / {
+ auth_basic "Restricted";
+ auth_basic_user_file /etc/nginx/auth.htpasswd;
- proxy_pass http://${FORWARD_HOST}:${FORWARD_PORT};
- proxy_read_timeout 900;
- }
+ proxy_pass http://${FORWARD_HOST}:${FORWARD_PORT};
+ proxy_read_timeout 900;
+ proxy_set_header Authorization "";
+ }
}
diff --git a/auth.htpasswd b/auth.htpasswd
deleted file mode 100644
index c30f02e..0000000
--- a/auth.htpasswd
+++ /dev/null
@@ -1 +0,0 @@
-${HTPASSWD}
\ No newline at end of file
diff --git a/docker-stack.yml b/docker-stack.yml
index dc4a7fd..6fa5740 100644
--- a/docker-stack.yml
+++ b/docker-stack.yml
@@ -1,35 +1,18 @@
-version: '3.1'
-
-# run with docker-compose:
-#
-# docker-compose -f docker-stack.yml up
-
-# run with docker swarm:
-#
-# docker swarm init
-# docker stack deploy --compose-file docker-stack.yml authdemo
-
-volumes:
- web-data:
-
services:
-
web:
- image: 'nginx'
- ## instead of an exposed port, use FORWARD_PORT in auth, below
- # ports:
- # - '80:80'
- volumes:
- - web-data:/usr/share/nginx/html:ro
-
+ image: nginx:stable-alpine-slim
+
auth:
- image: 'beevelop/nginx-basic-auth'
+ image: beevelop/nginx-basic-auth:latest
+ depends_on:
+ - web
ports:
- - '8080:80'
+ - "127.0.0.1:8080:80"
environment:
- - PORT=80
- - FORWARD_HOST=web
- - FORWARD_PORT=80
- ## escape $ with $$ in Docker yml due to variable expansion
- ## example user/pass generated with htpasswd is foo:bar
- - HTPASSWD=foo:$$apr1$$odHl5EJN$$KbxMfo86Qdve2FH4owePn.
+ HTPASSWD_FILE: /run/secrets/proxy_users
+ secrets:
+ - proxy_users
+
+secrets:
+ proxy_users:
+ file: ${PROXY_USERS_FILE:-./users.htpasswd}
diff --git a/launch.sh b/launch.sh
index e52beb9..89b886e 100755
--- a/launch.sh
+++ b/launch.sh
@@ -1,7 +1,58 @@
#!/bin/sh
+set -eu
-rm /etc/nginx/conf.d/default.conf || :
-envsubst < auth.conf > /etc/nginx/conf.d/auth.conf
-envsubst < auth.htpasswd > /etc/nginx/auth.htpasswd
+if [ "$1" != nginx ]; then
+ exec "$@"
+fi
-exec nginx -g "daemon off;"
+case "$FORWARD_HOST" in
+ ''|*[!a-zA-Z0-9._-]*)
+ echo 'FORWARD_HOST must be a DNS name or IPv4 address.' >&2
+ exit 1
+ ;;
+esac
+
+case "$FORWARD_PORT" in
+ ''|*[!0-9]*|??????*)
+ echo 'FORWARD_PORT must be an integer from 1 to 65535.' >&2
+ exit 1
+ ;;
+esac
+if [ "$FORWARD_PORT" -lt 1 ] || [ "$FORWARD_PORT" -gt 65535 ]; then
+ echo 'FORWARD_PORT must be an integer from 1 to 65535.' >&2
+ exit 1
+fi
+
+if [ -n "${HTPASSWD:-}" ] && [ -n "${HTPASSWD_FILE:-}" ]; then
+ echo 'Set only one of HTPASSWD or HTPASSWD_FILE.' >&2
+ exit 1
+fi
+if [ -z "${HTPASSWD:-}" ] && [ -z "${HTPASSWD_FILE:-}" ]; then
+ echo 'Set HTPASSWD or HTPASSWD_FILE before starting the proxy.' >&2
+ exit 1
+fi
+
+umask 077
+password_file=$(mktemp /etc/nginx/.auth.htpasswd.XXXXXX)
+trap 'rm -f "$password_file"' EXIT
+if [ -n "${HTPASSWD_FILE:-}" ]; then
+ cat "$HTPASSWD_FILE" > "$password_file"
+else
+ printf '%s\n' "$HTPASSWD" > "$password_file"
+fi
+if ! grep -qE '^[^:#[:space:]][^:]*:[^[:space:]]+' "$password_file"; then
+ echo 'Supply at least one htpasswd entry.' >&2
+ exit 1
+fi
+chgrp nginx "$password_file"
+chmod 0640 "$password_file"
+mv -f "$password_file" /etc/nginx/auth.htpasswd
+trap - EXIT
+
+rm -f /etc/nginx/conf.d/default.conf
+umask 022
+envsubst '${FORWARD_HOST} ${FORWARD_PORT}' \
+ < /opt/nginx-basic-auth/auth.conf.template \
+ > /etc/nginx/conf.d/auth.conf
+
+exec "$@"
From 11075e007d96a975bdf0d05ca36f1069de97bc8a Mon Sep 17 00:00:00 2001
From: Maik Hummel <6891349+beevelop@users.noreply.github.com>
Date: Thu, 3 Dec 2026 14:26:42 +0100
Subject: [PATCH 2/5] docs(readme): restore Docker image badge table
---
README.md | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
index ec56d28..ba9e93f 100644
--- a/README.md
+++ b/README.md
@@ -44,14 +44,21 @@ Pull requests build and exercise the proxy without registry credentials. GitHub
---
-## Related Beevelop images
+## All Docker images
| Badge | Pulls | Build Status | Release Date | Release |
| --- | --- | --- | --- | --- |
-| [](https://github.com/beevelop/docker-base) |  |  |  |  |
-| [](https://github.com/beevelop/docker-java) |  |  |  |  |
-| [](https://github.com/beevelop/docker-android) |  |  |  |  |
-| [](https://github.com/beevelop/docker-android-nodejs) |  |  |  |  |
-| [](https://github.com/beevelop/docker-cordova) |  |  |  |  |
-| [](https://github.com/beevelop/docker-ionic) |  |  |  |  |
-| [](https://github.com/beevelop/docker-nginx-basic-auth) |  |  |  |  |
+| [](https://github.com/beevelop/docker-base) | [](https://hub.docker.com/r/beevelop/base) | [](https://github.com/beevelop/docker-base/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-base/releases/latest) | [](https://github.com/beevelop/docker-base/releases/latest) |
+| [](https://github.com/beevelop/docker-java) | [](https://hub.docker.com/r/beevelop/java) | [](https://github.com/beevelop/docker-java/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-java/releases/latest) | [](https://github.com/beevelop/docker-java/releases/latest) |
+| [](https://github.com/beevelop/docker-android) | [](https://hub.docker.com/r/beevelop/android) | [](https://github.com/beevelop/docker-android/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-android/releases/latest) | [](https://github.com/beevelop/docker-android/releases/latest) |
+| [](https://github.com/beevelop/docker-android-nodejs) | [](https://hub.docker.com/r/beevelop/android-nodejs) | [](https://github.com/beevelop/docker-android-nodejs/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-android-nodejs/releases/latest) | [](https://github.com/beevelop/docker-android-nodejs/releases/latest) |
+| [](https://github.com/beevelop/docker-cordova) | [](https://hub.docker.com/r/beevelop/cordova) | [](https://github.com/beevelop/docker-cordova/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-cordova/releases/latest) | [](https://github.com/beevelop/docker-cordova/releases/latest) |
+| [](https://github.com/beevelop/docker-ionic) | [](https://hub.docker.com/r/beevelop/ionic) | [](https://github.com/beevelop/docker-ionic/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-ionic/releases/latest) | [](https://github.com/beevelop/docker-ionic/releases/latest) |
+| [](https://github.com/beevelop/docker-nginx-basic-auth) | [](https://hub.docker.com/r/beevelop/nginx-basic-auth) | [](https://github.com/beevelop/docker-nginx-basic-auth/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-nginx-basic-auth/releases/latest) | [](https://github.com/beevelop/docker-nginx-basic-auth/releases/latest) |
+| [](https://github.com/beevelop/docker-claude) | [](https://hub.docker.com/r/beevelop/claude) | [](https://github.com/beevelop/docker-claude/actions/workflows/docker.yml) | — | — |
+| [](https://github.com/beevelop/docker-nodejs) | [](https://hub.docker.com/r/beevelop/nodejs) | — | [](https://github.com/beevelop/docker-nodejs/releases/latest) | [](https://github.com/beevelop/docker-nodejs/releases/latest) |
+| [](https://github.com/beevelop/docker-nodejs-python) | [](https://hub.docker.com/r/beevelop/nodejs-python) | — | [](https://github.com/beevelop/docker-nodejs-python/releases/latest) | [](https://github.com/beevelop/docker-nodejs-python/releases/latest) |
+| [](https://github.com/beevelop/docker-uniqush) | [](https://hub.docker.com/r/beevelop/uniqush) | — | [](https://github.com/beevelop/docker-uniqush/releases/latest) | [](https://github.com/beevelop/docker-uniqush/releases/latest) |
+| [](https://github.com/beevelop/docker-shields) | [](https://hub.docker.com/r/beevelop/shields) | — | — | — |
+| [](https://github.com/beevelop/docker-directus) | — | Archived | [](https://github.com/beevelop/docker-directus/releases/latest) | [](https://github.com/beevelop/docker-directus/releases/latest) |
+| [](https://github.com/beevelop/docker-taiga-back) | — | Archived | [](https://github.com/beevelop/docker-taiga-back/releases/latest) | [](https://github.com/beevelop/docker-taiga-back/releases/latest) |
From 6daa1bf7c23301a8a8502ce7056666da92f23c72 Mon Sep 17 00:00:00 2001
From: Maik Hummel <6891349+beevelop@users.noreply.github.com>
Date: Thu, 3 Dec 2026 14:33:07 +0100
Subject: [PATCH 3/5] docs(readme): complete image badges and restore the
latest meme
---
README.md | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/README.md b/README.md
index ba9e93f..06dc110 100644
--- a/README.md
+++ b/README.md
@@ -46,19 +46,21 @@ Pull requests build and exercise the proxy without registry credentials. GitHub
## All Docker images
-| Badge | Pulls | Build Status | Release Date | Release |
-| --- | --- | --- | --- | --- |
-| [](https://github.com/beevelop/docker-base) | [](https://hub.docker.com/r/beevelop/base) | [](https://github.com/beevelop/docker-base/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-base/releases/latest) | [](https://github.com/beevelop/docker-base/releases/latest) |
-| [](https://github.com/beevelop/docker-java) | [](https://hub.docker.com/r/beevelop/java) | [](https://github.com/beevelop/docker-java/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-java/releases/latest) | [](https://github.com/beevelop/docker-java/releases/latest) |
-| [](https://github.com/beevelop/docker-android) | [](https://hub.docker.com/r/beevelop/android) | [](https://github.com/beevelop/docker-android/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-android/releases/latest) | [](https://github.com/beevelop/docker-android/releases/latest) |
-| [](https://github.com/beevelop/docker-android-nodejs) | [](https://hub.docker.com/r/beevelop/android-nodejs) | [](https://github.com/beevelop/docker-android-nodejs/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-android-nodejs/releases/latest) | [](https://github.com/beevelop/docker-android-nodejs/releases/latest) |
-| [](https://github.com/beevelop/docker-cordova) | [](https://hub.docker.com/r/beevelop/cordova) | [](https://github.com/beevelop/docker-cordova/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-cordova/releases/latest) | [](https://github.com/beevelop/docker-cordova/releases/latest) |
-| [](https://github.com/beevelop/docker-ionic) | [](https://hub.docker.com/r/beevelop/ionic) | [](https://github.com/beevelop/docker-ionic/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-ionic/releases/latest) | [](https://github.com/beevelop/docker-ionic/releases/latest) |
-| [](https://github.com/beevelop/docker-nginx-basic-auth) | [](https://hub.docker.com/r/beevelop/nginx-basic-auth) | [](https://github.com/beevelop/docker-nginx-basic-auth/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-nginx-basic-auth/releases/latest) | [](https://github.com/beevelop/docker-nginx-basic-auth/releases/latest) |
-| [](https://github.com/beevelop/docker-claude) | [](https://hub.docker.com/r/beevelop/claude) | [](https://github.com/beevelop/docker-claude/actions/workflows/docker.yml) | — | — |
-| [](https://github.com/beevelop/docker-nodejs) | [](https://hub.docker.com/r/beevelop/nodejs) | — | [](https://github.com/beevelop/docker-nodejs/releases/latest) | [](https://github.com/beevelop/docker-nodejs/releases/latest) |
-| [](https://github.com/beevelop/docker-nodejs-python) | [](https://hub.docker.com/r/beevelop/nodejs-python) | — | [](https://github.com/beevelop/docker-nodejs-python/releases/latest) | [](https://github.com/beevelop/docker-nodejs-python/releases/latest) |
-| [](https://github.com/beevelop/docker-uniqush) | [](https://hub.docker.com/r/beevelop/uniqush) | — | [](https://github.com/beevelop/docker-uniqush/releases/latest) | [](https://github.com/beevelop/docker-uniqush/releases/latest) |
-| [](https://github.com/beevelop/docker-shields) | [](https://hub.docker.com/r/beevelop/shields) | — | — | — |
-| [](https://github.com/beevelop/docker-directus) | — | Archived | [](https://github.com/beevelop/docker-directus/releases/latest) | [](https://github.com/beevelop/docker-directus/releases/latest) |
-| [](https://github.com/beevelop/docker-taiga-back) | — | Archived | [](https://github.com/beevelop/docker-taiga-back/releases/latest) | [](https://github.com/beevelop/docker-taiga-back/releases/latest) |
+| Badge | Docker Hub | Build Status | Published | Release / Tag | License |
+| --- | --- | --- | --- | --- | --- |
+| [](https://github.com/beevelop/docker-base) | [](https://hub.docker.com/r/beevelop/base)
[](https://hub.docker.com/r/beevelop/base)
[](https://hub.docker.com/r/beevelop/base/tags?name=latest) | [](https://github.com/beevelop/docker-base/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-base/releases/latest) | [](https://github.com/beevelop/docker-base/releases/latest)
[](https://calver.org/) | [](https://github.com/beevelop/docker-base/blob/latest/LICENSE) |
+| [](https://github.com/beevelop/docker-java) | [](https://hub.docker.com/r/beevelop/java)
[](https://hub.docker.com/r/beevelop/java)
[](https://hub.docker.com/r/beevelop/java/tags?name=latest) | [](https://github.com/beevelop/docker-java/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-java/releases/latest) | [](https://github.com/beevelop/docker-java/releases/latest)
[](https://calver.org/) | [](https://github.com/beevelop/docker-java/blob/latest/LICENSE) |
+| [](https://github.com/beevelop/docker-android) | [](https://hub.docker.com/r/beevelop/android)
[](https://hub.docker.com/r/beevelop/android)
[](https://hub.docker.com/r/beevelop/android/tags?name=latest) | [](https://github.com/beevelop/docker-android/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-android/releases/latest) | [](https://github.com/beevelop/docker-android/releases/latest)
[](https://calver.org/) | [](https://github.com/beevelop/docker-android/blob/latest/LICENSE) |
+| [](https://github.com/beevelop/docker-android-nodejs) | [](https://hub.docker.com/r/beevelop/android-nodejs)
[](https://hub.docker.com/r/beevelop/android-nodejs)
[](https://hub.docker.com/r/beevelop/android-nodejs/tags?name=latest) | [](https://github.com/beevelop/docker-android-nodejs/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-android-nodejs/releases/latest) | [](https://github.com/beevelop/docker-android-nodejs/releases/latest)
[](https://calver.org/) | [](https://github.com/beevelop/docker-android-nodejs/blob/latest/LICENSE) |
+| [](https://github.com/beevelop/docker-cordova) | [](https://hub.docker.com/r/beevelop/cordova)
[](https://hub.docker.com/r/beevelop/cordova)
[](https://hub.docker.com/r/beevelop/cordova/tags?name=latest) | [](https://github.com/beevelop/docker-cordova/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-cordova/releases/latest) | [](https://github.com/beevelop/docker-cordova/releases/latest)
[](https://calver.org/) | [](https://github.com/beevelop/docker-cordova/blob/latest/LICENSE) |
+| [](https://github.com/beevelop/docker-ionic) | [](https://hub.docker.com/r/beevelop/ionic)
[](https://hub.docker.com/r/beevelop/ionic)
[](https://hub.docker.com/r/beevelop/ionic/tags?name=latest) | [](https://github.com/beevelop/docker-ionic/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-ionic/releases/latest) | [](https://github.com/beevelop/docker-ionic/releases/latest)
[](https://calver.org/) | [](https://github.com/beevelop/docker-ionic/blob/latest/LICENSE) |
+| [](https://github.com/beevelop/docker-nginx-basic-auth) | [](https://hub.docker.com/r/beevelop/nginx-basic-auth)
[](https://hub.docker.com/r/beevelop/nginx-basic-auth)
[](https://hub.docker.com/r/beevelop/nginx-basic-auth/tags?name=latest) | [](https://github.com/beevelop/docker-nginx-basic-auth/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-nginx-basic-auth/releases/latest) | [](https://github.com/beevelop/docker-nginx-basic-auth/releases/latest)
[](https://calver.org/) | [](https://github.com/beevelop/docker-nginx-basic-auth/blob/latest/LICENSE) |
+| [](https://github.com/beevelop/docker-claude) | [](https://hub.docker.com/r/beevelop/claude)
[](https://hub.docker.com/r/beevelop/claude)
[](https://hub.docker.com/r/beevelop/claude/tags?name=latest) | [](https://github.com/beevelop/docker-claude/actions/workflows/docker.yml) | [](https://hub.docker.com/r/beevelop/claude/tags) | [](https://hub.docker.com/r/beevelop/claude/tags?name=latest)
[](https://calver.org/) | [](https://github.com/beevelop/docker-claude/blob/latest/LICENSE) |
+| [](https://github.com/beevelop/docker-nodejs) | [](https://hub.docker.com/r/beevelop/nodejs)
[](https://hub.docker.com/r/beevelop/nodejs)
[](https://hub.docker.com/r/beevelop/nodejs/tags?name=latest) | [](https://github.com/beevelop/docker-nodejs/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-nodejs/releases/latest) | [](https://github.com/beevelop/docker-nodejs/releases/latest)
[](https://calver.org/) | [](https://github.com/beevelop/docker-nodejs/blob/latest/LICENSE) |
+| [](https://github.com/beevelop/docker-nodejs-python) | [](https://hub.docker.com/r/beevelop/nodejs-python)
[](https://hub.docker.com/r/beevelop/nodejs-python)
[](https://hub.docker.com/r/beevelop/nodejs-python/tags?name=latest) | [](https://github.com/beevelop/docker-nodejs-python/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-nodejs-python/releases/latest) | [](https://github.com/beevelop/docker-nodejs-python/releases/latest)
[](https://calver.org/) | [](https://github.com/beevelop/docker-nodejs-python/blob/latest/LICENSE) |
+| [](https://github.com/beevelop/docker-uniqush) | [](https://hub.docker.com/r/beevelop/uniqush)
[](https://hub.docker.com/r/beevelop/uniqush)
[](https://hub.docker.com/r/beevelop/uniqush/tags?name=latest) | [](https://github.com/beevelop/docker-uniqush/actions/workflows/docker.yml) | [](https://github.com/beevelop/docker-uniqush/releases/latest) | [](https://github.com/beevelop/docker-uniqush/releases/latest)
[](https://calver.org/) | [](https://github.com/beevelop/docker-uniqush/blob/latest/LICENSE) |
+| [](https://github.com/beevelop/docker-shields) | [](https://hub.docker.com/r/beevelop/shields)
[](https://hub.docker.com/r/beevelop/shields)
[](https://hub.docker.com/r/beevelop/shields/tags?name=latest) | [](https://github.com/beevelop/docker-shields/actions) | [](https://hub.docker.com/r/beevelop/shields/tags) | [](https://hub.docker.com/r/beevelop/shields/tags?name=latest) | [](https://github.com/beevelop/docker-shields) |
+
+### Use tags where possible, because
+
+
From 7a42a9127ffe9ea326b908ed6cdaf81a2948d19c Mon Sep 17 00:00:00 2001
From: Maik Hummel <6891349+beevelop@users.noreply.github.com>
Date: Thu, 3 Dec 2026 15:35:44 +0100
Subject: [PATCH 4/5] fix(docker): preserve the published nginx proxy contract
---
.dockerignore | 6 +--
.github/scripts/smoke.sh | 101 +++++++++++++++++++++--------------
.github/workflows/docker.yml | 44 +++++++--------
.gitignore | 1 -
Dockerfile | 20 ++++---
README.md | 27 +++++-----
auth.conf | 15 +++---
auth.htpasswd | 1 +
docker-stack.yml | 43 ++++++++++-----
launch.sh | 59 ++------------------
10 files changed, 153 insertions(+), 164 deletions(-)
delete mode 100644 .gitignore
create mode 100644 auth.htpasswd
diff --git a/.dockerignore b/.dockerignore
index 42d2a6d..f4b1198 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,4 +1,2 @@
-*
-!Dockerfile
-!auth.conf
-!launch.sh
+.git
+.github
diff --git a/.github/scripts/smoke.sh b/.github/scripts/smoke.sh
index 63f709a..ba55143 100644
--- a/.github/scripts/smoke.sh
+++ b/.github/scripts/smoke.sh
@@ -19,61 +19,80 @@ cleanup() {
}
trap cleanup EXIT
+# Keep the inherited entrypoint, working directory, command, port and signal.
+docker image inspect "$image" --format '{{json .Config}}' | jq -e '
+ .Entrypoint == ["/docker-entrypoint.sh"]
+ and .Cmd == ["./launch.sh"]
+ and .WorkingDir == "/opt"
+ and .StopSignal == "SIGQUIT"
+ and (.ExposedPorts | keys) == ["80/tcp"]
+' >/dev/null
+docker run --rm "$image" sh -ec '
+ test "$PWD" = /opt
+ test -x ./launch.sh && test -f auth.conf && test -f auth.htpasswd
+ command -v envsubst >/dev/null
+ command -v curl >/dev/null
+ test -f /docker-entrypoint.d/20-envsubst-on-templates.sh
+'
+docker run --rm "$image" nginx -v
+
cat > "$scratch/backend.conf" <<'NGINX'
server {
- listen 8081;
+ listen 80;
+ listen 1337;
location / {
- return 200 "auth=$http_authorization uri=$request_uri";
+ return 200 "auth=$http_authorization port=$server_port uri=$request_uri";
}
}
NGINX
-record="smoke:$(openssl passwd -apr1 smoke-password)"
-# bcrypt fixture for smoke-password, matching the README’s htpasswd -B example.
-printf '%s\n' 'smoke:$2y$05$ABCDEFGHIJKLMNOPQRSTUOAkTpB.z20KXyNR5j2rJdcYl4myGhdKu' > "$scratch/users.htpasswd"
-
-# Without credentials, require the specific configuration error.
-if result=$(docker run --rm "$image" 2>&1); then
- echo 'The proxy started without credentials.' >&2
- exit 1
-fi
-[[ "$result" == *'Set HTPASSWD or HTPASSWD_FILE'* ]]
-
-# Reject a value that would terminate the proxy_pass directive.
-if result=$(docker run --rm -e FORWARD_HOST='backend;#' -e HTPASSWD="$record" "$image" 2>&1); then
- echo 'The proxy accepted an invalid upstream hostname.' >&2
- exit 1
-fi
-[[ "$result" == *'FORWARD_HOST must be'* ]]
docker network create "$network" >/dev/null
-docker run -d --name "$backend" --network "$network" --network-alias backend \
+docker run -d --name "$backend" --network "$network" --network-alias web --network-alias custom \
--mount "type=bind,src=$scratch/backend.conf,dst=/etc/nginx/conf.d/default.conf,readonly" \
--entrypoint nginx "$image" -g 'daemon off;' >/dev/null
-for credential_mode in file inline; do
- if [[ "$credential_mode" == file ]]; then
- credential_args=(
- -e HTPASSWD_FILE=/run/secrets/proxy_users
- --mount "type=bind,src=$scratch/users.htpasswd,dst=/run/secrets/proxy_users,readonly"
- )
- else
- credential_args=(-e HTPASSWD="$record")
- fi
- docker run -d --name "$proxy" --network "$network" -p 127.0.0.1::80 \
- -e FORWARD_HOST=backend -e FORWARD_PORT=8081 "${credential_args[@]}" "$image" >/dev/null
+start_proxy() {
+ docker run -d --name "$proxy" --network "$network" -p 127.0.0.1::80 "$@" "$image" >/dev/null
endpoint="http://$(docker port "$proxy" 80/tcp)/probe?one=two"
+ local status=
for _ in {1..20}; do
- if status=$(curl --noproxy '*' -s -o /dev/null -w '%{http_code}' --max-time 2 "$endpoint"); then
- break
+ if status=$(curl --noproxy '*' -s -o /dev/null -w '%{http_code}' --max-time 2 "$endpoint") &&
+ [[ "$status" == 401 ]]; then
+ return
fi
sleep 1
done
- [[ "$status" == 401 ]]
- [[ $(curl --noproxy '*' -s -o /dev/null -w '%{http_code}' --max-time 3 \
- -u smoke:wrong-password "$endpoint") == 401 ]]
- [[ $(curl --noproxy '*' -fsS --max-time 3 -u smoke:smoke-password "$endpoint") \
- == 'auth= uri=/probe?one=two' ]]
- docker rm -f "$proxy" >/dev/null
- printf 'Proxy passed with %s credentials.\n' "$credential_mode"
-done
+ printf 'Expected an anonymous 401, received %s\n' "$status" >&2
+ return 1
+}
+
+check_credentials() {
+ local credentials=$1
+ local upstream_port=$2
+ local authorization
+ authorization=$(printf '%s' "$credentials" | base64 -w 0)
+ [[ $(curl --noproxy '*' -fsS --max-time 3 -u "$credentials" "$endpoint") \
+ == "auth=Basic $authorization port=$upstream_port uri=/probe?one=two" ]]
+}
+
+start_proxy
+[[ $(curl --noproxy '*' -s -o /dev/null -w '%{http_code}' --max-time 3 \
+ -u foo:wrong-password "$endpoint") == 401 ]]
+curl --noproxy '*' -s -o /dev/null -D "$scratch/headers" --max-time 3 "$endpoint"
+grep -Fiq 'WWW-Authenticate: Basic realm="Restricted"' "$scratch/headers"
+check_credentials foo:bar 80
+docker rm -f "$proxy" >/dev/null
+
+printf -v records 'one:%s\ntwo:%s' "$(openssl passwd -apr1 first)" "$(openssl passwd -apr1 second)"
+start_proxy -e FORWARD_HOST=custom -e FORWARD_PORT=1337 -e HTPASSWD="$records"
+check_credentials one:first 1337
+check_credentials two:second 1337
+[[ $(curl --noproxy '*' -s -o /dev/null -w '%{http_code}' --max-time 3 -u foo:bar "$endpoint") == 401 ]]
+docker rm -f "$proxy" >/dev/null
+
+start_proxy -e HTPASSWD= -e FORWARD_HOST='[::1]' -e FORWARD_PORT=000080
+docker exec "$proxy" grep -Fq 'http://[::1]:000080' /etc/nginx/conf.d/auth.conf
+[[ $(curl --noproxy '*' -s -o /dev/null -w '%{http_code}' --max-time 3 -u foo:bar "$endpoint") == 401 ]]
+
+printf 'Legacy defaults, inline authentication, upstream forwarding, and command overrides passed.\n'
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 3671b81..f7b41b2 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -2,12 +2,12 @@ name: Docker Image
on:
schedule:
- - cron: '17 10 * * 2'
+ - cron: '0 10 * * *'
workflow_dispatch:
pull_request:
- branches: [latest]
push:
- branches: [latest]
+ # Validate the winter clean through its pull request without publishing a review tag.
+ branches-ignore: [winter-clean-2026]
tags: ['v*.*.*']
permissions:
@@ -18,23 +18,27 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
- IMAGE: beevelop/nginx-basic-auth
- PUBLISH: >-
- ${{ github.repository == 'beevelop/docker-nginx-basic-auth' &&
- github.actor != 'dependabot[bot]' &&
- ((github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) ||
- (github.event_name != 'pull_request' && github.ref == 'refs/heads/latest')) }}
+ PLATFORMS: linux/amd64,linux/arm64/v8,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
+ PUBLISH: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
jobs:
main:
runs-on: ubuntu-24.04
- timeout-minutes: 20
+ timeout-minutes: 30
steps:
- name: Check out the repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
+ - name: Set image name
+ run: printf 'IMAGE=%s\n' "${GITHUB_REPOSITORY/docker-/}" >> "$GITHUB_ENV"
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
+ with:
+ platforms: arm64,arm,ppc64le,s390x
+
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
@@ -46,10 +50,11 @@ jobs:
with:
context: .
platforms: linux/amd64
+ pull: true
load: true
tags: nginx-basic-auth:smoke
- - name: Test HTTP authentication and forwarding
+ - name: Test the existing proxy contract
run: bash .github/scripts/smoke.sh nginx-basic-auth:smoke
- name: Generate image tags and labels
@@ -66,26 +71,23 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- # The Dockerfile only copies files into the base image, so no emulation is needed.
- - name: Publish multi-platform image
- if: env.PUBLISH == 'true'
- id: publish
+ - name: Build all supported platforms
+ id: release
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
- platforms: linux/amd64,linux/arm64/v8,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
- push: true
+ platforms: ${{ env.PLATFORMS }}
+ pull: true
+ push: ${{ env.PUBLISH == 'true' }}
+ outputs: ${{ env.PUBLISH != 'true' && 'type=cacheonly' || '' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- provenance: mode=min
- sbom: true
- name: Report critical and high CVEs with Docker Scout
if: env.PUBLISH == 'true'
- continue-on-error: true
uses: docker/scout-action@b265cd48f8a1451d2680815b3e8dc4ed65ee16e7 # v1.30.0
with:
command: cves
- image: ${{ env.IMAGE }}@${{ steps.publish.outputs.digest }}
+ image: ${{ env.IMAGE }}@${{ steps.release.outputs.digest }}
only-severities: critical,high
exit-code: false
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 621b261..0000000
--- a/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/users.htpasswd
diff --git a/Dockerfile b/Dockerfile
index f9bdd0e..bf92667 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,10 +1,16 @@
-FROM nginx:1.30.8-alpine-slim@sha256:e9eaa7298465eab06d618c51556fdcf3fb5061f9ff40bd28ee898fbd7ee7f900
+FROM nginx:1.31.10-alpine@sha256:7fc0fb4af7bf006aeb31aea88069976060f8f0a0a86b667126742cc17f4e31ae
-ENV FORWARD_HOST=web \
- FORWARD_PORT=80
+ENV HTPASSWD='foo:$apr1$odHl5EJN$KbxMfo86Qdve2FH4owePn.' \
+ FORWARD_PORT=80 \
+ FORWARD_HOST=web
-COPY auth.conf /opt/nginx-basic-auth/auth.conf.template
-COPY --chmod=0755 launch.sh /usr/local/bin/launch.sh
+WORKDIR /opt
-ENTRYPOINT ["/usr/local/bin/launch.sh"]
-CMD ["nginx", "-g", "daemon off;"]
+RUN apk add --no-cache gettext
+
+COPY auth.conf auth.htpasswd launch.sh ./
+
+# make sure root login is disabled
+RUN sed -i -e 's/^root::/root:!:/' /etc/shadow
+
+CMD ["./launch.sh"]
diff --git a/README.md b/README.md
index 06dc110..7637d77 100644
--- a/README.md
+++ b/README.md
@@ -4,34 +4,33 @@
# Nginx Basic Auth proxy
-Protect an HTTP service behind nginx with HTTP Basic authentication. This image uses nginx 1.30.8 stable on Alpine and listens on container port 80. The nginx master initializes the configuration and workers run as the `nginx` user.
+Protect an HTTP service behind nginx with HTTP Basic authentication. This image uses the full nginx 1.31.10 Alpine base and listens on container port 80.
## Quickstart
-Use Docker Compose and an `htpasswd` file. On Debian and Ubuntu, install `apache2-utils` if `htpasswd` is missing.
+Run the proxy and an example upstream on the same Docker network.
```sh
-git clone https://github.com/beevelop/docker-nginx-basic-auth.git
-cd docker-nginx-basic-auth
-(umask 077; htpasswd -cB users.htpasswd alice)
-docker compose -f docker-stack.yml up -d
-curl -u alice http://127.0.0.1:8080/
+docker network create nginx-auth-demo
+docker run -d --network nginx-auth-demo --name web nginx:alpine
+docker run -d --network nginx-auth-demo --name auth \
+ -p 127.0.0.1:8080:80 beevelop/nginx-basic-auth
+curl -u foo:bar http://127.0.0.1:8080/
```
-Run `htpasswd -B users.htpasswd another-user` to add users. Omit `-c` when updating an existing file. The example proxies a welcome page on the Compose network, where only the proxy is exposed to the host. Change the `web` service to your upstream and set `FORWARD_PORT` if it listens on another port. Run `docker compose -f docker-stack.yml down` to stop the example. This example binds to loopback in Compose. Swarm ingress publishes on all host interfaces even when a loopback address is specified.
+The example credentials are `foo` and `bar`. Supply your own password records with `HTPASSWD` when deploying the proxy. The existing [Compose and Swarm example](docker-stack.yml) can also run the demo.
## Configuration
| Variable | Default | Description |
| --- | --- | --- |
-| `HTPASSWD_FILE` | | Path inside the container to a readable `htpasswd` file. Prefer a Compose secret or a read-only mount. |
-| `HTPASSWD` | | Inline `htpasswd` records separated by newlines. Single-quote literal records to protect `$` characters in hashes. |
-| `FORWARD_HOST` | `web` | Upstream hostname or IPv4 address, resolvable inside the container. |
+| `HTPASSWD` | `foo` / `bar` | Inline htpasswd records separated by newlines. Single-quote literal records to preserve dollar signs in hashes. |
+| `FORWARD_HOST` | `web` | Upstream address reachable from the container. |
| `FORWARD_PORT` | `80` | Upstream HTTP port. |
-Supply exactly one credential option. Upgrading from an older image requires configuring your own credentials if the deployment used the previous `foo` / `bar` default. Existing `HTPASSWD` records continue to work. Recreate the proxy to apply credential changes or resolve a replaced upstream hostname again.
+For a custom login, create an htpasswd file with a tool such as `htpasswd -cB users.htpasswd alice`, then pass its contents as `-e HTPASSWD="$(cat users.htpasswd)"` when creating the container. One record per line enables multiple users. Compose YAML requires literal dollar signs in inline hashes to be escaped as `$$`.
-For plain `docker run`, attach both containers to the same user-defined network and use the upstream container name as `FORWARD_HOST`. Mount the credentials file with `--mount type=bind,src="$(pwd)/users.htpasswd",dst=/run/secrets/proxy_users,readonly` and set `-e HTPASSWD_FILE=/run/secrets/proxy_users`. For remote clients, terminate HTTPS at a trusted gateway in front of this proxy. The proxy consumes the Basic credentials and omits the `Authorization` header when forwarding upstream.
+The proxy forwards the client's Authorization header to the upstream after successful authentication. The launcher renders the templates from `/opt` into `/etc/nginx` on startup.
## Build and test
@@ -40,7 +39,7 @@ docker build -t nginx-basic-auth:local .
bash .github/scripts/smoke.sh nginx-basic-auth:local
```
-Pull requests build and exercise the proxy without registry credentials. GitHub Actions publishes from `latest` and `v*.*.*` release tags, with a weekly scheduled refresh of `nightly` and `latest`. Prefer a release tag or image digest when deploying.
+Pull requests exercise the existing proxy contract and build all seven supported platforms. Scheduled builds refresh `latest` and `nightly` daily at 10:00 UTC. Branch pushes, version tags, and manual runs can publish as before. Use a release tag or digest when you need to pin a deployment.
---
diff --git a/auth.conf b/auth.conf
index 01095e5..aaebd2e 100644
--- a/auth.conf
+++ b/auth.conf
@@ -1,12 +1,11 @@
server {
- listen 80 default_server;
+ listen 80 default_server;
- location / {
- auth_basic "Restricted";
- auth_basic_user_file /etc/nginx/auth.htpasswd;
+ location / {
+ auth_basic "Restricted";
+ auth_basic_user_file auth.htpasswd;
- proxy_pass http://${FORWARD_HOST}:${FORWARD_PORT};
- proxy_read_timeout 900;
- proxy_set_header Authorization "";
- }
+ proxy_pass http://${FORWARD_HOST}:${FORWARD_PORT};
+ proxy_read_timeout 900;
+ }
}
diff --git a/auth.htpasswd b/auth.htpasswd
new file mode 100644
index 0000000..c30f02e
--- /dev/null
+++ b/auth.htpasswd
@@ -0,0 +1 @@
+${HTPASSWD}
\ No newline at end of file
diff --git a/docker-stack.yml b/docker-stack.yml
index 6fa5740..dc4a7fd 100644
--- a/docker-stack.yml
+++ b/docker-stack.yml
@@ -1,18 +1,35 @@
+version: '3.1'
+
+# run with docker-compose:
+#
+# docker-compose -f docker-stack.yml up
+
+# run with docker swarm:
+#
+# docker swarm init
+# docker stack deploy --compose-file docker-stack.yml authdemo
+
+volumes:
+ web-data:
+
services:
- web:
- image: nginx:stable-alpine-slim
+ web:
+ image: 'nginx'
+ ## instead of an exposed port, use FORWARD_PORT in auth, below
+ # ports:
+ # - '80:80'
+ volumes:
+ - web-data:/usr/share/nginx/html:ro
+
auth:
- image: beevelop/nginx-basic-auth:latest
- depends_on:
- - web
+ image: 'beevelop/nginx-basic-auth'
ports:
- - "127.0.0.1:8080:80"
+ - '8080:80'
environment:
- HTPASSWD_FILE: /run/secrets/proxy_users
- secrets:
- - proxy_users
-
-secrets:
- proxy_users:
- file: ${PROXY_USERS_FILE:-./users.htpasswd}
+ - PORT=80
+ - FORWARD_HOST=web
+ - FORWARD_PORT=80
+ ## escape $ with $$ in Docker yml due to variable expansion
+ ## example user/pass generated with htpasswd is foo:bar
+ - HTPASSWD=foo:$$apr1$$odHl5EJN$$KbxMfo86Qdve2FH4owePn.
diff --git a/launch.sh b/launch.sh
index 89b886e..e52beb9 100755
--- a/launch.sh
+++ b/launch.sh
@@ -1,58 +1,7 @@
#!/bin/sh
-set -eu
-if [ "$1" != nginx ]; then
- exec "$@"
-fi
+rm /etc/nginx/conf.d/default.conf || :
+envsubst < auth.conf > /etc/nginx/conf.d/auth.conf
+envsubst < auth.htpasswd > /etc/nginx/auth.htpasswd
-case "$FORWARD_HOST" in
- ''|*[!a-zA-Z0-9._-]*)
- echo 'FORWARD_HOST must be a DNS name or IPv4 address.' >&2
- exit 1
- ;;
-esac
-
-case "$FORWARD_PORT" in
- ''|*[!0-9]*|??????*)
- echo 'FORWARD_PORT must be an integer from 1 to 65535.' >&2
- exit 1
- ;;
-esac
-if [ "$FORWARD_PORT" -lt 1 ] || [ "$FORWARD_PORT" -gt 65535 ]; then
- echo 'FORWARD_PORT must be an integer from 1 to 65535.' >&2
- exit 1
-fi
-
-if [ -n "${HTPASSWD:-}" ] && [ -n "${HTPASSWD_FILE:-}" ]; then
- echo 'Set only one of HTPASSWD or HTPASSWD_FILE.' >&2
- exit 1
-fi
-if [ -z "${HTPASSWD:-}" ] && [ -z "${HTPASSWD_FILE:-}" ]; then
- echo 'Set HTPASSWD or HTPASSWD_FILE before starting the proxy.' >&2
- exit 1
-fi
-
-umask 077
-password_file=$(mktemp /etc/nginx/.auth.htpasswd.XXXXXX)
-trap 'rm -f "$password_file"' EXIT
-if [ -n "${HTPASSWD_FILE:-}" ]; then
- cat "$HTPASSWD_FILE" > "$password_file"
-else
- printf '%s\n' "$HTPASSWD" > "$password_file"
-fi
-if ! grep -qE '^[^:#[:space:]][^:]*:[^[:space:]]+' "$password_file"; then
- echo 'Supply at least one htpasswd entry.' >&2
- exit 1
-fi
-chgrp nginx "$password_file"
-chmod 0640 "$password_file"
-mv -f "$password_file" /etc/nginx/auth.htpasswd
-trap - EXIT
-
-rm -f /etc/nginx/conf.d/default.conf
-umask 022
-envsubst '${FORWARD_HOST} ${FORWARD_PORT}' \
- < /opt/nginx-basic-auth/auth.conf.template \
- > /etc/nginx/conf.d/auth.conf
-
-exec "$@"
+exec nginx -g "daemon off;"
From c69a7550212032c0113a15dc2f16552a87838d8e Mon Sep 17 00:00:00 2001
From: Maik Hummel <6891349+beevelop@users.noreply.github.com>
Date: Thu, 3 Dec 2026 15:38:00 +0100
Subject: [PATCH 5/5] fix(docker): preserve published template file permissions
---
.github/scripts/smoke.sh | 3 +++
Dockerfile | 6 ++++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/.github/scripts/smoke.sh b/.github/scripts/smoke.sh
index ba55143..97ba9fd 100644
--- a/.github/scripts/smoke.sh
+++ b/.github/scripts/smoke.sh
@@ -34,6 +34,9 @@ docker run --rm "$image" sh -ec '
command -v curl >/dev/null
test -f /docker-entrypoint.d/20-envsubst-on-templates.sh
'
+docker run --rm --user 65534:65534 "$image" sh -ec '
+ test -r auth.conf && test -r auth.htpasswd && test -x launch.sh
+'
docker run --rm "$image" nginx -v
cat > "$scratch/backend.conf" <<'NGINX'
diff --git a/Dockerfile b/Dockerfile
index bf92667..04515b3 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -10,7 +10,9 @@ RUN apk add --no-cache gettext
COPY auth.conf auth.htpasswd launch.sh ./
-# make sure root login is disabled
-RUN sed -i -e 's/^root::/root:!:/' /etc/shadow
+# Preserve the published file permissions and disable root login.
+RUN chmod 0644 auth.conf auth.htpasswd \
+ && chmod 0755 launch.sh \
+ && sed -i -e 's/^root::/root:!:/' /etc/shadow
CMD ["./launch.sh"]