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

Centos Certbot 使用

  1. 安装
    可选配置:启动EPEL存储库 非必要项
yum install -y epel-release
yum clean all
yum makecache
#启用可选通道  可以不配置
yum -y install yum-utils
yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional

必要配置参数:安装certbot

yum -y install certbot python2-certbot-nginx
  1. 配置nginx
upstream proxy {server 127.0.0.1:9000;
}
server {listen 443;server_name  test.test.com;location ~ ^/(base|admin|web|assets|auth|user) {proxy_redirect          off;proxy_set_header        X-Proxy-Client-IP $remote_addr;proxy_set_header        Host $http_host;proxy_set_header        X-Real-IP $remote_addr;proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header        X-Forwarded-Proto $scheme;proxy_pass              http://proxy;}location / {root /data/camc/public/dist;# project pathtry_files $uri /index.html;# if not match,go to the save pageindex  index.html index.htm;}error_page  404              /404.html;                                                                                                           error_page   500 502 503 504  /50x.html;location = /50x.html {root   /usr/share/nginx/html;}}
#http直接重定向到https
server {listen 80;server_name test.test.com;rewrite ^(.*)$ https://$host$1 permanent;}

或是一个正常的侦听80端口的也可以,重点是下一步生成证书,
3. 生成证书
3.1自动配置nginx
运行如下命令会自动下载证书并配置nginx。

certbot --nginx

会列表nginx下的域名列表,从其中选择2中配置的域名,会自动生成ssl文件并配置好443端口

3.2 手动配置nginx
运行如下命令会自动下载证书但需要自己配置nginx。

certbot certonly --nginx

若nginx未安装在默认路径(/etc/nginx or /usr/local/etc/nginx)下需自己指定nginx路径,到conf目录

certbot certonly --nginx --nginx-server-root=/root/nginx/conf
  1. 自动更新
sudo crontab -e
0 0 1 * * /usr/bin/certbot renew  >> /var/log/le-renew.log
http://www.lryc.cn/news/97415.html

相关文章:

  • VL163的基本信息
  • IntelliJ IDEA 2023.2 新版本,拥抱 AI
  • softmax回归
  • .NET 8 Preview 5推出!
  • Spring核心概念、IoC和DI的认识、Spring中bean的配置及实例化、bean的生命周期
  • git冲突“accept theirs”和“accept yours”
  • Vision Transformer (ViT)
  • OpenGL Metal Shader 编程:解决图片拉伸变形问题
  • [SQL挖掘机] - 字符串函数 - concat
  • Rust之所有权
  • RabbitMQ帮助类的封装
  • mac 移动硬盘未正常退出,再次链接无法读取(显示)
  • 短视频账号矩阵系统源码开发部署路径
  • 前端 | ( 十一)CSS3简介及基本语法(上) | 尚硅谷前端html+css零基础教程2023最新
  • Kafka入门到起飞系列 - 副本机制,什么是副本因子呢?
  • 2023年基准Kubernetes报告:6个K8s可靠性失误
  • 程序员面试系列,k8s常见面试题
  • docker版jxTMS使用指南:站点的调整
  • element ui input 深层循环v-model绑定默认数据删除不了的情况
  • GBDT的参数空间与超参数优化
  • 多线程练习——抽奖箱
  • RK3399平台开发系列讲解(内核调试篇)Valgrind 内存调试与性能分析
  • Windows 11的最新人工智能应用Windows Copilot面世!
  • Mac 预览(Preview)丢失PDF标注恢复
  • 4.5. 方法的四种类型
  • 四旋翼无人机使用教程
  • 优化 PHP 数据库查询性能
  • vue 使用stompjs websocket连接rabbitmq
  • com.android.ide.common.signing.KeytoolException:
  • leetcode 1870. Minimum Speed to Arrive on Time(准时到达的最小速度)