$ mkdir -p /data $ cd /data $ git clone https://ghproxy.com/https://github.com/gcdd1993/nginx-certbot $ cd nginx-certbot $ ls -l drwxr-xr-x 4 root root 4096 Jun 8 22:01 ./ drwxr-xr-x 5 root root 4096 Jun 8 21:49 ../ drwxr-xr-x 4 root root 4096 Jun 8 21:53 data/ -rw-r--r-- 1 root root 660 Jun 8 21:49 docker-compose.yml drwxr-xr-x 8 root root 4096 Jun 8 21:49 .git/ -rw-r--r-- 1 root root 14 Jun 8 21:49 .gitignore -rwxr-xr-x 1 root root 2286 Jun 8 22:01 init-letsencrypt.sh* -rw-r--r-- 1 root root 1074 Jun 8 21:49 LICENSE -rw-r--r-- 1 root root 1376 Jun 8 21:49 README.md
修改邮箱
1 2 3 4
$ vim init-letsencrypt.sh ... email="gcwm99@gmail.com" ...
修改操作域名
修改your_domain为你的域名(只能是单域名,不能是泛域名)
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
执行脚本
出现以下内容,说明已经成功!
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.