$ certbot certonly --nginx Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator nginx, Installer nginx Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): lyc7456@qq.com # 输入邮箱地址 Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must agree in order to register with the ACME server at https://acme-v02.api.letsencrypt.org/directory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (A)gree/(C)ancel: A # 同意协议
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you be willing to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: n
Which names would you like to activate HTTPS for? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: test1.lyc7456.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shown (Enter 'c' to cancel): 1 # 选择一个当前nginx下的站点域名 Obtaining a new certificate Performing the following challenges: http-01 challenge for test1.lyc7456.com Waiting for verification... Cleaning up challenges
IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/test1.lyc7456.com/fullchain.pem # 证书 Your key file has been saved at: /etc/letsencrypt/live/test1.lyc7456.com/privkey.pem Your cert will expire on 2020-06-26. To obtain a new or tweaked # 证书密钥 version of this certificate in the future, simply run certbot again. To non-interactively renew *all* of your certificates, run "certbot renew" - Your account credentials have been saved in your Certbot configuration directory at /etc/letsencrypt. You should make a secure backup of this folder now. This configuration directory will also contain certificates and private keys obtained by Certbot so making regular backups of this folder is ideal. - If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
3.Nginx添加ssl配置
nginx的vhosts配置,可以通过 certbot –nginx 创建证书时自动添加配置
https
1 2 3 4 5
listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/test1.lyc7456.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/test1.lyc7456.com/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
http强制跳转https
1 2 3 4 5 6 7 8 9 10 11
server { if ($host = test1.lyc7456.com) { return 301 https://$host$request_uri; } # managed by Certbot
listen 80; server_name test1.lyc7456.com; return 404; # managed by Certbot