https://github.com/beevelop/docker-nginx-basic-auth
:closed_lock_with_key: Simple Docker image for basic authentication
https://github.com/beevelop/docker-nginx-basic-auth
authentication container-image containerization docker docker-image nginx
Last synced: 4 months ago
JSON representation
:closed_lock_with_key: Simple Docker image for basic authentication
- Host: GitHub
- URL: https://github.com/beevelop/docker-nginx-basic-auth
- Owner: beevelop
- License: mit
- Created: 2016-06-25T07:05:11.000Z (over 9 years ago)
- Default Branch: latest
- Last Pushed: 2023-10-18T21:53:28.000Z (about 2 years ago)
- Last Synced: 2025-04-02T11:54:43.910Z (9 months ago)
- Topics: authentication, container-image, containerization, docker, docker-image, nginx
- Language: Dockerfile
- Homepage: https://beevelop.com
- Size: 25.4 KB
- Stars: 152
- Watchers: 6
- Forks: 97
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README





[](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
