使用Certbot申请免费 HTTPS 证书及自动续期

随着各个脚本的安全性越来越差,越来越多的我倾向于自行编译lnmp环境。但自行编译环境申请SSL证书一直是个问题,今天给大家介绍一个好用的工具:CertBot来实现证书的申请及自动续期。

以下所有操作均运行在 Debian服务器。本机环境是Debian12

首先,我们要安装 Snapd

 

  1. su root
  2. apt update
  3. apt install snapd

安装Snapd-core

 

  1. sudo snap install core

安装CertBot

 

  1. sudo snap install –classic certbot

链接CertBot到/usr/bin目录

 

  1. sudo ln -s /snap/bin/certbot /usr/bin/certbot

给nginx环境安装证书,指定nginx的conf目录和nginx的执行目录,配置证书是自动完成的。

 

  1. certbot –nginx –nginx-server-root=/usr/local/nginx/conf –nginx-ctl=/usr/local/nginx/sbin/nginx

以下是自动申请证书的输出结果,中间需要输入邮箱及一些确认。

 

  1. Saving debug log to /var/log/letsencrypt/letsencrypt.log
  2. Enter email address (used for urgent renewal and security notices)
  3. (Enter ‘c’ to cancel): admin@1stcache.com
  4. – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
  5. Please read the Terms of Service at
  6. https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf. You must
  7. agree in order to register with the ACME server. Do you agree?
  8. – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
  9. (Y)es/(N)o: y
  10. – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
  11. Would you be willing, once your first certificate is successfully issued, to
  12. share your email address with the Electronic Frontier Foundation, a founding
  13. partner of the Let’s Encrypt project and the non-profit organization that
  14. develops Certbot? We’d like to send you email about our work encrypting the web,
  15. EFF news, campaigns, and ways to support digital freedom.
  16. – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
  17. (Y)es/(N)o: y
  18. Account registered.
  19. Which names would you like to activate HTTPS for?
  20. We recommend selecting either all domains, or all domains in a VirtualHost/server block.
  21. – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
  22. 1: oss.1stcache.com
  23. – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
  24. Select the appropriate numbers separated by commas and/or spaces, or leave input
  25. blank to select all options shown (Enter ‘c’ to cancel): 1
  26. Requesting a certificate for oss.1stcache.com
  27. Successfully received certificate.
  28. Certificate is saved at: /etc/letsencrypt/live/oss.1stcache.com/fullchain.pem
  29. Key is saved at: /etc/letsencrypt/live/oss.1stcache.com/privkey.pem
  30. This certificate expires on 2024-02-14.
  31. These files will be updated when the certificate renews.
  32. Certbot has set up a scheduled task to automatically renew this certificate in the background.
  33. Deploying certificate
  34. Successfully deployed certificate for oss.1stcache.com to /usr/local/nginx/conf/nginx.conf
  35. Congratulations! You have successfully enabled HTTPS on https://oss.1stcache.com
  36. – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
  37. If you like Certbot, please consider supporting our work by:
  38. * Donating to ISRG / Let’s Encrypt: https://letsencrypt.org/donate
  39. * Donating to EFF: https://eff.org/donate-le
  40. – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
  41. root@sweaty-balance:/usr/local/nginx#

现在再使用https来访问我们的网站,发现已经大功告成了。

别急,我们需要全自动续期呢。

 

  1. sudo certbot renew –dry-run

这个命令会帮我们自动续期,现在才算ok了。

  1. /etc/crontab/
  2. /etc/cron.*/*
  3. systemctl list-timers

查看以上目录确认续期ok。

整个流程其实非常简单。脱离面板其实也没有那么难。

小车博客下载必看

给TA打赏
共{{data.count}}人
人已打赏
大杂烩

cloudflare workers+fastly 组合优选节点实现更好的上网体验

2023-11-15 21:56:31

大杂烩

网红短剧7千+部附转存工具及短剧搜索网址及H5页面

2024-3-27 10:17:07




重要声明

本站资源来自会员发布以及互联网收集,不代表本站立场,如有侵犯你的权益请联系管理员-车车站内发信联系 我们会第一时间进行审核删除。站内资源为网友个人学习或测试研究使用,未经原版权作者许可,禁止用于任何商业途径!请用户仔细辨认内容的真实性,避免上当受骗!本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。请在下载24小时内删除!


如果遇到付费才可观看的文章,建议升级终身VIP。全站所有资源任意下免费看”。本站资源少部分采用7z压缩,为防止有人压缩软件不支持7z格式,7z解压,建议下载7-zip,zip、rar解压,建议下载WinRAR

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索