Skip to content

Latest commit

History

27 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Docker image of Nginx Proxy with Basic Auth

Docker Repository on Quay

Simple HTTP Proxy with Basic Authentication

 w/ user:pass +------------------------+ +-------------+
User ---------------> | nginx-basic-auth-proxy | ---> | HTTP Server |
+------------------------+ +-------------+

This project is a fork of dtan4's nginx basic auth proxy. I only added a couple of common monitoring endpoints (/healthz, /ping, /status, /metrics and /version) to be accessible without basic auth.

Run

$ docker run \
--rm \
--name nginx-basic-auth-proxy \
-p 8080:80 \
-p 8090:8090 \
-e BASIC_AUTH_USERNAME=username \
-e BASIC_AUTH_PASSWORD=password \
-e PROXY_PASS=https://www.google.com \
-e SERVER_NAME=proxy.dtan4.net \
-e PORT=80 \
quay.io/thomasjungblut/nginx-basic-auth-proxy

Access to http://localhost:8080 , then browser asks you username and password.

You can also try complete HTTP-proxy example using Docker Compose. hello-world web application cannot be accessed without authentication.

$ docker-compose up
# http://localhost:8080/# - Username: username# - Password: password

Endpoint for monitoring

:8090/nginx_status returns the metrics of Nginx.

$ curl localhost:8090/nginx_statusActive connections: 1server accepts handled requests 8 8 8Reading: 0 Writing: 1 Waiting: 0

Environment variables

Required

KeyDescription
BASIC_AUTH_USERNAMEBasic auth username
BASIC_AUTH_PASSWORDBasic auth password
PROXY_PASSProxy destination URL

Optional

KeyDescriptionDefault
SERVER_NAMEValue for server_name directiveexample.com
PORTValue for listen directive80
CLIENT_MAX_BODY_SIZEValue for client_max_body_size directive1m
PROXY_READ_TIMEOUTValue for proxy_read_timeout directive60s
WORKER_PROCESSESValue for worker_processes directiveauto

Original Author

Daisuke Fujita (@dtan4)

License

MIT License

About

Docker image of Nginx Proxy with Basic Auth

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages