A Docker template based on the docker-nginx-letsencrypt-sample project.
This creates the following containers:
In the example setup the website called sample-website and is configured in the following places:
Copy any files you need served into the volumes/nginx-sample-website/content directory.
Every website added should have the following configuration set:
volumes:
- "./volumes/your_website/conf.d/:/etc/nginx/conf.d"
- "./volumes/your_website/content/:/usr/share/nginx/html/"
environment:
- VIRTUAL_HOST=your_website,www.your_website
- VIRTUAL_NETWORK=nginx-proxy
- VIRTUAL_PORT=80
- LETSENCRYPT_HOST=your_website,www.your_website
- LETSENCRYPT_EMAIL=your_email@something.com
Remember to match the VIRTUAL_HOST and LETSENCRYPT_HOST used with those specified in the _servername attribute of your config file at __volumes/your_website/conf.d/your.conf__
If you need to restrict access to hidden files and directories ensure that letsencrypt can still access the /.well-known/acme-challenge/ directory with the following nginx config:
location ~ /.well-known/acme-challenge/ {
allow all;
}
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
In the main directory run:
docker-compose up
Remove all containers from /app dir - removes stale data inside the containers such as letencrypt config:
docker-compose down
Remove all docker images for Dockerfiles that have changed as this will force a rebuild of the image:
docker image rm name
Remove all volumes to ensure updated config is detected:
docker volume ls | awk '{if(NR>1)print}' | tr -s " " | cut -d " " -f2 | xargs docker volume rm
If you can't remove some volumes because they are being used, you can either remove the hashes of the containers using the volumes with:
docker stop HASH
docker rm HASH
or remove all containers with:
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
ACME_CA_URI=https://acme-staging.api.letsencrypt.org/directory
DEBUG=true
docker-compose logs
.docker exec -ti nginx cat /etc/nginx/conf.d/default.conf
docker-compose down
docker exec letsencrypt-nginx-proxy-companion /app/cert_status
to see if the certificate is valid