当前位置: 首页 > news >正文

使用certbot为网站启用https

1. 安装certbot客户端

cd /usr/local/bin
wget https://dl.eff.org/certbot-auto
chmod a+x ./certbot-auto

2. 创建目录和配置nginx用于验证域名 

    mkdir -p /data/www/letsencryptserver {listen 80;server_name ~^(?<subdomain>.+).ninvfeng.com;location /.well-known/ {root /data/www/letsencrypt;allow all;}location / {return 301 https://$subdomain.ninvfeng.com$request_uri;}}

3. 生成证书

certbot-auto certonly --webroot -w /data/www/letsencrypt -d jianli.ninvfeng.com

 4. 配置nginx https

server {listen       443;server_name  jianli.ninvfeng.com;root /data/www/jianli;location / {index index.php index.html;}location ~ \.php$ {fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}if (!-e $request_filename) {rewrite ^/(.*) /index.php?$1 last;}ssl on;ssl_certificate /etc/letsencrypt/live/jianli.ninvfeng.com/fullchain.pem;ssl_certificate_key /etc/letsencrypt/live/jianli.ninvfeng.com/privkey.pem;ssl_session_timeout  5m;ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_prefer_server_ciphers   on;
}

该方法生成的证书有效期为90天, 在到期前我们需要执行以下命令更新证书

certbot-auto renew0 0 1 * * certbot-auto renew  --quiet --renew-hook "nginx -s reload"

 

http://www.lryc.cn/news/327306.html

相关文章:

  • Unity 背包系统中拖拽物体到指定位置或互换位置效果的实现
  • iOS客户端自动化UI自动化airtest+appium从0到1搭建macos+脚本设计demo演示+全网最全最详细保姆级有步骤有图
  • 每周编辑精选|在线运行 Deepmoney 金融大模型、AI 偏好等多个优质数据集上线
  • C++多重继承与虚继承
  • 请简单介绍一下Shiro框架是什么?Shiro在Java安全领域的主要作用是什么?Shiro主要提供了哪些安全功能?
  • TouchGFX之Button
  • 计算机组成原理 — 指令系统
  • 使用easyYapi生成文档
  • 蓝桥杯练习题总结(三)线性dp题(摆花、数字三角形加强版)
  • Elasticsearch(15) multi_match的使用
  • nodejs的线程模型和libuv库的基本使用
  • Uni-app/Vue/Js本地模糊查询,匹配所有字段includes和some方法结合使用e
  • 深度学习pytorch——激活函数损失函数(持续更新)
  • 《苹果 iOS 应用开发与分发的关键问题解析》
  • 爱上数据结构:顺序表和链表
  • python知识点总结(十)
  • 【Python】探索 Python 编程世界:常量、变量及数据类型解析
  • vue页面实现左右div宽度,上下div高度分割线手动拖动高度或者宽度自动变化,两个div宽度或者高度拉伸调节,实现左右可拖动改变宽度的div内容显示区
  • 知攻善防应急靶场-Linux(1)
  • ffmpeg命令行
  • VMware虚拟机更换引导顺序
  • RAFT:让大型语言模型更擅长特定领域的 RAG 任务
  • Stable Diffusion 本地训练端口与云端训练端口冲突解决办法
  • C++学习day1
  • openGauss CM
  • 北斗短报文+4G应急广播系统:实时监控 自动预警 保护校园安全的新力量
  • 2024河北石家庄矿业矿山展览会|河北智慧矿山展会|河北矿博会
  • ruoyi使用笔记
  • 论文《Exploring to Prompt for Vision-Language Models》阅读
  • 科普 | Runes 预挖矿概念