Automatically create and renew SSL certificates with Certbot and Nginx using the Let's Encrypt free certificate authority into the Docker environment.
How to use CA key with NGINX for SSL(HTTPS)
## Step:0. Change the nginx.conf content to your domain name
## Step:1. Config your nginx.conf with your Email and Domain name and then Running 'docker run"
docker run -itd --name test --network=host \
-v "${PWD}"/nginx.conf:/etc/nginx/conf.d/nginx.conf \
-v "${PWD}"/nginx.sh:/etc/nginx/nginx.sh -v "${PWD}"/cronjob:/etc/cron.d/cronjob \
-v "${PWD}"/:/etc/letsencrypt/ \
williehao/nginx-cert:v20.04
## Step:2. Get a CA Key from your host's direction
ls *** (your domain name)
## if you didn't see CA key please use "find" command line to find CA key location
sudo find / -name fullchain.pem
## Step3: Combine CA key to another container(APP) which wants to use CA Key: (For example: Ant-Media-Server)
Docker run -v "${PWD}"/:/etc/letsencrypt/ ***
Please check your environment has already had:
- Domain name EX: www.google.com
- IPV6 address
- 80 Port (for Let's Encrypt checking your Domain name )
- Docker
- A Domain name is okay (EX: ping6 www.google.com)
- An IPV6 address is already (EX:ifconfig)
- 80 port check (EX: telnet www.google.com 80)
docker run -itd --name test --network=host \
-v "${PWD}"/nginx.conf:/etc/nginx/conf.d/nginx.conf \
-v "${PWD}"/nginx.sh:/etc/nginx/nginx.sh -v "${PWD}"/cronjob:/etc/cron.d/cronjob \
-v "${PWD}"/:/etc/letsencrypt/ \
williehao/nginx-cert:v20.04
PS: don't use "--rm" if you want to auto-update CA key
you can check log file from crontab.log or /var/log/letsencrypt/letsencrypt.log, which will give you very more detailed messages
### in the container
ls /etc/letsencrypt/live/***.***.com/
### in the Docker environment
ls live
1.Q: too many certificates (5) already issued for this exact set of domains in the last 168 hours
A: waiting for the time because this rate limit is exceeded when a subscriber requests a certificate for the same “exact set” of hostnames more than 5 times in a single week
Reference
2.Q: too many failed authorizations recently
A: Change Email address