博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
让你的网站秒配 HTTPS 证书
阅读量:7122 次
发布时间:2019-06-28

本文共 1756 字,大约阅读时间需要 5 分钟。

原谅我当一次标题党

网站为什么要配置 HTTPS,以及配置 HTTPS 有什么优点就不再解释了,我们直奔主题,使用 Certbot 工具让你的网站秒配 HTTPS 证书。

Certbot

介绍

Certbot is an easy-to-use client that fetches a certificate from Let’s Encrypt—an open certificate authority launched by the EFF, Mozilla, and others—and deploys it to a web server.

Certbot是由 Let’s Encrypt 一个开放免费证书颁发机构的EFF、Mozilla和其他开发者推出的,易于客户端获取网站加密证书。 自嘲:英语翻译的好烂(^o^)

特点

  • 简单易用、免费
  • 自动化配置
  • 证书无限免费续签
  • 效率极高,一次安装,再配置其他站点 https 证书只需要 3 分钟

PS: 因为测试服务器站点过多,每次使用 acme-tiny 脚本配置证书都要十多分钟时间,为了提高效率,就使用了 Let's Encrypt 官网推荐的自动部署脚本。

官方网站:

certbot官方网站.png

  1. 选择自己的服务器和操作系统环境,Certbot 官方会给出详细的安装过程和使用方法,我的环境是 Nginx + Ubuntu 14.04,安装过程如下
$ sudo apt-get update$ sudo apt-get install software-properties-common$ sudo add-apt-repository ppa:certbot/certbot$ sudo apt-get update$ sudo apt-get install python-certbot-nginx

安装成功之后把 certbot 加入系统全局变量 PATH 中。

  1. 获取证书前需要先停止 Nginx 服务

service nginx stop

  1. 生成单域名证书

certbot certonly --standalone --email your@email.com -d yourdomain.com

一次生成多域名证书:

certbot certonly --standalone --email your@email.com -d yourdomain.com -d yourdomain2.com

证书配置成功后提示:

image.png

4.查看网站生成的证书

tree /etc/letsencrypt/live/

5.配置 Nginx

…… 其他配置    listen 443 ssl;    ssl_certificate   /etc/letsencrypt/live/{yourdomain}.com/fullchain.pem;    ssl_certificate_key  /etc/letsencrypt/live/{yourdomain}.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;

6.重启 Nginx

service nginx start

此时再加上 https:// 访问你的网站,就会有一把可爱别致的小绿锁 Secure^_^

Let’s Encrypt 生成的免费证书为3个月时间,使用 certbot renew 可以无限免费续签 Https 证书

certbot renew

  • 在生成证书的时候遇到一个问题
    Problem binding to port 443: Could not bind to IPv4 or IPv6.. Skipping

这是因为 nginx 服务没有关闭,执行 service nginx stop 即可。

觉得有用是不是该点赞呢?

转载地址:http://dwsel.baihongyu.com/

你可能感兴趣的文章
java中子类实例化过程中的内存分配
查看>>
二叉树——数据结构课堂作业
查看>>
scp 命令
查看>>
springmvc+mybatis多数据源配置,AOP注解动态切换数据源
查看>>
JavaScript-数据类型
查看>>
你们还好意思再骂慈禧太后吗?
查看>>
yum install ruby出错:error downloading packages
查看>>
Linux 下编译安装OpenCV【转】
查看>>
platform_get_resource的分析
查看>>
《Linux内核设计与实现》读书笔记 - 目录 (完结)【转】
查看>>
底部导航栏使用BottomNavigationBar
查看>>
math对象
查看>>
Storm介绍及核心组件和编程模型
查看>>
Eclipse添加maven之后报错 Eclipse is running in a JRE, but a JDK is required 解决方法
查看>>
Sql Server的艺术(二) SQL复杂条件搜索
查看>>
C#执行osql脚本时部分脚本未执行
查看>>
IIS服务命令
查看>>
Java基础之中间件的初识
查看>>
下载软件的临时文件思路和实现
查看>>
修改Linux系统默认编辑器
查看>>