Repository: beevelop/docker-nginx-basic-auth
Branch: latest
Commit: b2b12f843721
Files: 9
Total size: 12.3 KB
Directory structure:
gitextract_pa3lvg89/
├── .github/
│ ├── dependabot.yml
│ └── workflows/
│ └── docker.yml
├── Dockerfile
├── LICENSE
├── README.md
├── auth.conf
├── auth.htpasswd
├── docker-stack.yml
└── launch.sh
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 1
groups:
github-actions:
patterns:
- "*"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 1
groups:
docker:
patterns:
- "*"
================================================
FILE: .github/workflows/docker.yml
================================================
name: Docker Image
on:
schedule:
- cron: "0 10 * * *" # everyday at 10am
workflow_dispatch:
pull_request:
branches: ["**"]
push:
branches: ["**"]
tags: ["v*.*.*"]
env:
platforms: linux/amd64,linux/arm64/v8,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
jobs:
main:
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- name: Check out the repo
uses: actions/checkout@v6
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
with:
images: ${{ env.imageName }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to DockerHub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v7
with:
platforms: ${{ env.platforms }}
push: ${{ github.event_name != 'pull_request' }}
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' }}
uses: docker/scout-action@v1
with:
command: cves
image: ${{ env.imageName }}:${{ steps.docker_meta.outputs.version }}
only-severities: critical,high
exit-code: false
================================================
FILE: Dockerfile
================================================
FROM nginx:alpine
ENV HTPASSWD='foo:$apr1$odHl5EJN$KbxMfo86Qdve2FH4owePn.' \
FORWARD_PORT=80 \
FORWARD_HOST=web
WORKDIR /opt
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"]
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2016-2021 Maik Hummel (beevelop)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================





[](https://github.com/beevelop/docker-nginx-basic-auth/releases)


[](https://beevelop.com)
# Docker Nginx Basic Auth - Simple Authentication Proxy
> Lightweight nginx reverse proxy with HTTP basic authentication for securing Docker containers and web applications.
## 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`.
## 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
```
> Use single quotes to prevent unwanted interpretation of `$` signs!
## 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
```
results in 2 users (`foo:bar` and `test:test`).
## Troubleshooting
**Error: `nginx: [emerg] host not found in upstream "web"`**
- Ensure you link the container as `web` using `--link foobar:web`
## Limitations
- SSL/HTTPS is not currently supported
- For SSL requirements, consider using `jwilder/nginx-proxy` as a central gateway with `VIRTUAL_HOST` environment variable
---
# 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) |  |  |  |  |
---

### Use tags where possible, because

================================================
FILE: auth.conf
================================================
server {
listen 80 default_server;
location / {
auth_basic "Restricted";
auth_basic_user_file auth.htpasswd;
proxy_pass http://${FORWARD_HOST}:${FORWARD_PORT};
proxy_read_timeout 900;
}
}
================================================
FILE: auth.htpasswd
================================================
${HTPASSWD}
================================================
FILE: docker-stack.yml
================================================
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
auth:
image: 'beevelop/nginx-basic-auth'
ports:
- '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.
================================================
FILE: launch.sh
================================================
#!/bin/sh
rm /etc/nginx/conf.d/default.conf || :
envsubst < auth.conf > /etc/nginx/conf.d/auth.conf
envsubst < auth.htpasswd > /etc/nginx/auth.htpasswd
exec nginx -g "daemon off;"
gitextract_pa3lvg89/ ├── .github/ │ ├── dependabot.yml │ └── workflows/ │ └── docker.yml ├── Dockerfile ├── LICENSE ├── README.md ├── auth.conf ├── auth.htpasswd ├── docker-stack.yml └── launch.sh
Condensed preview — 9 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (13K chars).
[
{
"path": ".github/dependabot.yml",
"chars": 398,
"preview": "version: 2\nupdates:\n - package-ecosystem: \"github-actions\"\n directory: \"/\"\n schedule:\n interval: \"daily\"\n "
},
{
"path": ".github/workflows/docker.yml",
"chars": 1893,
"preview": "name: Docker Image\n\non:\n schedule:\n - cron: \"0 10 * * *\" # everyday at 10am\n workflow_dispatch:\n pull_request:\n "
},
{
"path": "Dockerfile",
"chars": 314,
"preview": "FROM nginx:alpine\n\nENV HTPASSWD='foo:$apr1$odHl5EJN$KbxMfo86Qdve2FH4owePn.' \\\n FORWARD_PORT=80 \\\n FORWARD_HOST=web"
},
{
"path": "LICENSE",
"chars": 1094,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2016-2021 Maik Hummel (beevelop)\n\nPermission is hereby granted, free of charge, to "
},
{
"path": "README.md",
"chars": 7639,
"preview": ". The extraction includes 9 files (12.3 KB), approximately 3.7k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.