官网:https://letsencrypt.org/zh-cn

官网建议使用Certbot的方式进行安装,所以首先我们需要安装Certbot

Certbot)

官网:Certbot (eff.org)

选择运行的机器与系统的对应信息,选择之后页面会进行跳转,我这边使用的是Centos8+NGINX, 会跳转到页面:Certbot - Centosrhel8 Nginx (eff.org)

1.需要登录服务器

2.安装snapd工具(Installing snap on CentOS | Snapcraft documentation

1)查看Centos版本

cat /etc/centos-release

2)添加epel源

$ sudo dnf install epel-release
$ sudo dnf upgrade

3)安装snapd

sudo yum install snapd

#加入systemd管理进程
sudo systemctl enable --now snapd.socket # 添加classic支持
sudo ln -s /var/lib/snapd/snap /snap

安装完成之后, 需要新打开一个终端, 重新进入, 即可使用snapd相关命令

3.安装snap之后,要升级到最新的版本

sudo snap install core; sudo snap refresh core

4.移除老的之前安装过的Certbot工具删除掉

sudo apt-get remove certbot

sudo dnf remove certbot

sudo yum remove certbot

5.安装Certbot

sudo snap install --classic certbot

创建软链接:

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

6.对nginx生成证书

certbot --nginx

#如果配置不是默认的位置 (/etc/nginx or /usr/local/etc/nginx),需要手动指定配置文件所在目录
certbot certonly --nginx --nginx-server-root=/root/nginx/conf

正常的话,就顺利生成了证书与Key:

进行nginx配置:

server    {
listen 80;
server_name xx.xx.com;
access_log /data/log/nginx/access_xx.xx.com_80.log main buffer=10k flush=5s;
error_log /data/log/nginx/error_xx.xx.com_80.log warn; location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
} } server {
listen 443 ssl;
server_name xx.xx.com;
access_log /data/log/nginx/access_xx.xx.com_443.log main;
error_log /data/log/nginx/error_xx.xx.com_443.log warn; ssl_certificate /etc/letsencrypt/live/xx.xx.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/xx.xx.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; location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
} }

然后重新加载配置文件即可:

nginx -t

nginx -s reload

7.测试证书到期自动更换

sudo certbot renew --dry-run

这个时候  就可以使用https访问一下啦~~~

注意点:

1.nginx需要支持SSL

nginx -V

查看是否加载模块: --with-http_ssl_module

参考:

SSL免费证书之Let’s Encrypt的更多相关文章

  1. Letsencrypt SSL免费证书申请(Docker)

    最近需要SSL证书,又不想花钱买,正好看到linux基金会去年底上线了新的开源项目,免费推广SSL遂尝试. Let's Encrypt 介绍 Let’s Encrypt is a free, auto ...

  2. Java Web学习总结(31)——全站HTTPS化SSL免费证书使用

    1 背景 谷歌从 2017 年起,Chrome 浏览器将也会把采用 HTTP 协议的网站标记为「不安全」网站:苹果从 2017 年 iOS App 将强制使用 HTTPS:在国内热火朝天的小程序也要求 ...

  3. Nginx+tomcat+ssl免费证书配置

    0.说明 本文说描写叙述的方式是用nginx的443重定向到tomcat的8443,nginx的80port重定到tomcat的8080: 乱入:个人标记:caicongyang 1.nginx安装 ...

  4. 阿里云使用ssl免费证书

    购买免费证书 购买之后 申请证书 该域名必须添加一条TXT记录 根据提示添加记录 下载证书 我用的nginx做的映射,所以下载nginx nginx安装自行百度 将下载的文件解压到nginx目录下(创 ...

  5. SSL免费证书申请以及nginx配置https流程记录

    设置https需要ssl 证书,可以通过FreeSSL[https://freessl.org/]申请. 流程记录: 输入域名,如 http://www.youdias.xin 选择品牌,如Let's ...

  6. 免费证书申请——Let's Encrypt的申请与应用(IIS,Tomcat)

    环境 Windows Server 2008 R2 Tomcat 8.5.31 JDK8 利用IIS+letsencrypt-win-simple.V1.9.1申请免费SSL证书 新建一个IIS空网站 ...

  7. Ubuntu 16.04配置SSL免费证书

    主要参考地址为:https://blog.csdn.net/setoy/article/details/78441613 本篇主要以Apache这个web服务器来讲解,所以前提必须要安装好apache ...

  8. https(ssl) 免费证书

    https://letsencrypt.org/getting-started/ https://certbot.eff.org/lets-encrypt/centosrhel7-nginx http ...

  9. HTTPS(SSL / TLS)免费证书申请及网站证书部署实战总结

    服务器环境:windows server 2008  +  tomcat7 废话不多说,先看部署效果: 一.免费证书申请 Let's Encrypt  简介:let's Encrypt 是一个免费的开 ...

  10. docker项目ssl 安全证书的种种

    一,证书挂着宿主的nginx上 这个很简单,只需要修改宿主nginx的配置文件即可 server { ssl default; server_name www.abc.com; #项目域名 ssl_c ...

随机推荐

  1. 公有云-实验一 实践腾讯云部署Web应用

    实验一 实践腾讯云部署Web应用 概述 企业A需要搭建一套在互联网上发布的论坛平台,但是企业内部并没有完善的基础架构设施,难以保证论坛平台的高可用性和高安全性.经过IT部门相关专家分析讨论,决定在腾讯 ...

  2. 初步认识uboot

    1. uboot下载地址 ftp://ftp.denx.de/pub/u-boot/

  3. springboot 基本配置文件

    spring.datasource.url=jdbc:mysql://127.0.0.1:3306/game?useUnicode=true&zeroDateTimeBehavior=conv ...

  4. 【赵渝强老师】在Hive中使用Load语句加载数据

    一.Hive中load语句的语法说明 Hive Load语句不会在加载数据的时候做任何转换工作,而是纯粹的把数据文件复制/移动到Hive表对应的地址.语法格式如下: LOAD DATA [LOCAL] ...

  5. SpringBoot 实现文件上传

    参考:Java springboot进阶教程 文件上传功能实现 后端代码编写 常见错误分析与解决 在 Service 业务层接口中增加一个上传文件的方法 因为文件并不是上传至数据库中,所以不需要编写 ...

  6. CPU缓存伪共享

    CPU缓存什么东西?当然这个问题很多人有可能觉得比较傻,CPU缓存什么,肯定是缓存数据(代码)啊,要不然还能缓存啥,这个确实没问题,但是CPU到底缓存什么样的数据呢?因为对CPU来说,无论是指令,还是 ...

  7. 各位Oracle DBA们,你们期待的在线实训环境终于来了

    各位Oracle DBA,你们是否曾在学习.工作时遇到不得不上正式库测试的情况,如果没事发生那一切岁月静好,但若一不小心删了用户.删了表甚至删了库,可就是悲剧了--从做出开库测试这个决定起,胆战心惊就 ...

  8. docker-compose -- 创建 redis && mysql

    version: '3' services: nest-admin-web: image: buqiyuan/vue3-antdv-admin:stable container_name: nest- ...

  9. NJU ICS2024 PA 作业心得(一)

    NJU ICS2024 PA 作业心得(一) 由于自己并不是NJU 2024的学生,因此"堂而皇之"的把这份心得发在了网上,并且只是仅供非以此课程作为自己当前学年保研课的同学参考. ...

  10. AvaloniaTCP-v1.0.0:学习使用Avalonia/C#进行TCP通讯的一个简单Demo

    TCP通讯简介 TCP(传输控制协议,Transmission Control Protocol)是一种面向连接的.可靠的.基于字节流的传输层通信协议.它确保数据包按顺序传输,并在必要时进行重传,以保 ...