Quick Setup Guide
Get started quickly with Nginx-Proxy by following these setup instructions for the proxy and your containers.
Quick Setup
Setup nginx-proxy
docker pull mesudip/nginx-proxy
docker network create frontend; # create a network for nginx proxy
docker run --network frontend \
--name nginx-proxy \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /etc/ssl:/etc/ssl \
-v /etc/nginx/dhparam:/etc/nginx/dhparam \
-p 80:80 \
-p 443:443 \
-d --restart always mesudip/nginx-proxy
Setup your container
The only thing that matters is that the container shares at least one common network to the nginx container and VIRTUAL_HOST
environment variable is set.
Examples:
- WordPress
docker run --network frontend \
--name wordpress-server \
-e VIRTUAL_HOST="wordpress.example.com" \
wordpress
- Docker Registry
docker run --network frontend \
--name docker-registry \
-e VIRTUAL_HOST='https://registry.example.com/v2 -> /v2; client_max_body_size 2g' \
-e PROXY_BASIC_AUTH="registry.example.com -> user1:password,user2:password2,user3:password3" \
registry:2
# Configure `nginx-proxy`
Following directries can be made into volumes to persist configurations
- `/etc/nginx/conf.d` nginx configuration directory. You can add your own server configurations here
- `/etc/nginx/dhparam` the directory for storing DH parameter for ssl connections
- `/etc/ssl` directory for storing ssl certificates, ssl private key and Let's Encrypt account key.
- `/var/log/nginx` directory nginx logs
- `/tmp/acme-challenges` directory for storing challenge content when registering Let's Encrypt certificate
Some of the default behaviour of `nginx-proxy` can be changed with environment variables.
- `DHPARAM_SIZE` Default - `2048` : Set size of dhparam usd for ssl certificates
- `CLIENT_MAX_BODY_SIZE` Default - `1m` : Set default max body size for all the servers.