https://github.com/danielwhatmuff/nginx-ssl-auth-docker
Docker build for nginx with basic auth and SSL termination
https://github.com/danielwhatmuff/nginx-ssl-auth-docker
Last synced: 5 months ago
JSON representation
Docker build for nginx with basic auth and SSL termination
- Host: GitHub
- URL: https://github.com/danielwhatmuff/nginx-ssl-auth-docker
- Owner: danielwhatmuff
- Created: 2016-05-05T23:57:38.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-06T01:42:19.000Z (about 10 years ago)
- Last Synced: 2025-06-21T23:38:57.840Z (12 months ago)
- Language: Nginx
- Size: 6.84 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NGINX SSL reverse proxy to another Docker container, with basic auth
## Overview
- Provides SSL termination using NGINX running inside a Docker container
- Provides basic auth, using htpassword file
- Forward requests securely to a linked container, or to another backend
- Logs nginx access_log messages to stdout
## Usage
- Create certificate, key and Diffie-Hellman cert
```bash
$ openssl dhparam -out dh.pem 2048
$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout cert.key -out cert.crt
```
- Create .htpasswd file
```
$ htpasswd -c .htpasswd username
```
- Build image
```
$ docker build -t nginx-ssl-auth .
```
- Run the container you wish to proxy to
```
$ docker run -d --name myservice
```
- Run the nginx-ssl-auth container, pass environment variables and mount certs/htpasswd/dhparam
```
$ docker run -d --link myservice \
-e 'LINKED_CONTAINER_NAME=myservice' \
-e 'LINKED_CONTAINER_PORT=8080' \
-p 80:80 \
-p 443:443 \
-v $(pwd)/cert.crt:/etc/nginx/cert.crt \
-v $(pwd)/cert.key:/etc/nginx/cert.key \
-v $(pwd)/dh.pem:/etc/nginx/dh.pem \
-v $(pwd)/.htpasswd:/etc/nginx/.htpasswd \
nginx-ssl-auth
```
- Note: The '--link myservice' must match the container name and the port must match too