如果你想发现代码中隐藏的BUG,欢迎免费试用最专业的BUG实时监控平台Fundebug! 4. 申请证书使用certbot命令为www.fundebug.com申请HTTPS证书。--nginx选项表示Web服务器为nginx,-d选项指定域名,-n选项表示非交互式运行命令。若去除**-n**选项,则终端会提醒你选择是否将http请求重定向为https请求。
certbot --nginx -d www.fundebug.com -n
证书申请成功之后,会看到以下信息。Let's Encrypt证书的有效期只有3个月,但是Certbot会通过Cron和systemd timer自动更新证书,证书的时效性不用担心。
IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/www.fundebug.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/www.fundebug.com/privkey.pem Your cert will expire on 2018-09-29. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. To non-interactively renew *all* of your certificates, run "certbot renew" - 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
HTTPS证书相关的文件在**/etc/letsencrypt/**目录中:
find /etc/letsencrypt/ -name "*www.fundebug.com*"/etc/letsencrypt/renewal/www.fundebug.com.conf/etc/letsencrypt/archive/www.fundebug.com/etc/letsencrypt/live/www.fundebug.com
certbot会自动修改nginx配置文件:
cat /etc/nginx/conf.d/fundebug.conf
nginx监听了443端口并配置了HTTPS证书,这时我们可以通过HTTPS协议访问了!www.fundebug.com
server{ listen 80; server_name www.fundebug.com; listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/www.fundebug.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/www.fundebug.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} 参考