云中客

梦想有多大,就能走多远

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  138 随笔 :: 3 文章 :: 173 评论 :: 30万 阅读
  1. 按照自动设置工具
$ apt-get update
$ sudo apt-get install certbot
$ apt-get install python3-certbot-nginx
  1. 配置Nginx
    /etc/nginx/conf.d
server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html;
    server_name example.com www.example.com;
}
  1. 更新配置
nginx -t && nginx -s reload
  1. 自动生成SSL并配置
$ sudo certbot --nginx -d example.com -d www.example.com
  • 如果只生成证书可以用
sudo certbot certonly --nginx
  1. 出现下面消息代表配置成功
Congratulations! You have successfully enabled https://example.com and https://www.example.com 

-------------------------------------------------------------------------------------
IMPORTANT NOTES: 

Congratulations! Your certificate and chain have been saved at: 
/etc/letsencrypt/live/example.com/fullchain.pem 
Your key file has been saved at: 
/etc/letsencrypt/live/example.com//privkey.pem
Your cert will expire on 2017-12-12.
  1. 查看更新后的配置文件
server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html;
    server_name  example.com www.example.com;

    listen 443 ssl; # managed by Certbot

    # RSA certificate
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot

    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot

    # Redirect non-https traffic to https
    if ($scheme != "https") {
        return 301 https://$host$request_uri;
    } # managed by Certbot
}
  1. 到期自动更新设置
    每天0点check是不是剩下30天期限,然后更新
crontab -e
0 12 * * * /usr/bin/certbot renew --quiet
posted on 2021-06-20 18:30  走遍江湖  阅读(223)  评论(0)    收藏  举报
编辑推荐:
· 优雅求模,一致性哈希算法
· 解疑释惑 - 日志体系之 slf4j + logback 组合(一)
· 平滑加权轮询负载均衡的底层逻辑
· C# 13 与 .NET 9 跨平台开发实战 - 第一章
· DDD领域驱动设计的理解
阅读排行:
· 《HelloGitHub》第 113 期
· Git提交错了,别慌!还有后悔药
· 开源一套Microsoft Office COM 组件的 .NET 封装
· ElasticSearch是什么?
· 优雅求模,一致性哈希算法
点击右上角即可分享
微信分享提示

喜欢请打赏

扫描二维码打赏

支付宝打赏