nginx-proxy

the following details how to use nginx-proxy to host multiple docker containers (nginx-proxy guide)

  • create docker network docker network create nginx-proxy
  • install nginx-proxy container docker run -d --name nginx-proxy \ -p 80:80 \ --net nginx-proxy \ -v /var/run/docker.sock:/tmp/docker.sock \ jwilder/nginx-proxy

letsencrypt companion

in order to use the letsencrypt companion container with nginx-proxy we need to modify the nginx-proxy run command slightly

```
docker run -d --name nginx-proxy \
    -p 80:80 -p 443:443 \
    --net nginx-proxy \
    -v /etc/nginx/certs \
    -v /etc/nginx/vhost.d \
    -v /usr/share/nginx/html \
    -v /var/run/docker.sock:/tmp/docker.sock:ro \
    jwilder/nginx-proxy
```

then we can run the letsencrypt-nginx-proxy-companion container

```
docker run -d --name nginx-proxy-letsencrypt \
    --volumes-from nginx-proxy \
    -v /var/run/docker.sock:/var/run/docker.sock:ro \
    -e "DEFAULT_EMAIL=root@pyratebeard.net" \
    jrcs/letsencrypt-nginx-proxy-companion
```

to start the application containers add the VIRTUAL_HOST and LETSENCRYPT_HOST variables using my log container as an example

```
docker run -d --name "$CONTAINER_NAME" \
    --expose 1313 \
    --net nginx-proxy \
    -e VIRTUAL_HOST=log.pyratebeard.net \
    -e LETSENCRYPT_HOST=log.pyratebeard.net \
    -v $(pwd):/src \
    $CI_REGISTRY_IMAGE
```