$ vim init-letsencrypt.sh ... email="gcwm99@gmail.com" ...
2、修改操作域名
1 2
$ sed -i 's/example.org/your_domain/g' data/nginx/app.conf \ && sed -i 's/example.org/your_domain/g' init-letsencrypt.sh
3、执行init-letsencrypt.sh
直到出现以下内容,说明已经完成
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
$ ./init-letsencrypt.sh ... Requesting a certificate for your_domain
Successfully received certificate. Certificate is saved at: /etc/letsencrypt/live/your_domain/fullchain.pem Key is saved at: /etc/letsencrypt/live/your_domain/privkey.pem This certificate expires on 2021-09-06. These files will be updated when the certificate renews.
NEXT STEPS: - The certificate will need to be renewed before it expires. Certbot can automatically renew the certificate in the background, but you may need to take steps to enable that functionality. See https://certbot.org/renewal-setup for instructions.
listen443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/your_domain/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/your_domain/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
server_tokensoff; } server { if ($host = your_domain) { return301 https://$host$request_uri; } # managed by Certbot
server_name your_domain; listen80; return404; # managed by Certbot }
更新证书
作者给出的docker-compose.yml已经默认12小时检查并更新一次,所以非常省心
1 2 3 4 5
$ docker exec -it nginx-certbot_certbot_1 certbot renew ... The following certificates are not due for renewal yet: /etc/letsencrypt/live/your_domain/fullchain.pem expires on 2021-09-06 (skipped) No renewals were attempted.