IT基础设施:在CentOS7中为nginx布署免费SSL证书

简介: 前言此前在阿里申请了免费的SSL证书,但每个人只有20个证书的额度,此额度是一次性、永久性的,也就是说,到期的证书也算;由于各种各样的原因,我的测试额度已经满了。

前言

此前在阿里申请了免费的SSL证书,但每个人只有20个证书的额度,此额度是一次性、永久性的,也就是说,到期的证书也算;由于各种各样的原因,我的测试额度已经满了。于是转粉腾讯云,结果腾讯这边直接审核不通过,顿时心凉;猛然间想起咱们还有Let's Encrypt's,立马感觉生活又有了希望。

img_71a68b83b7f6d74f2270671c1ecc4025.png
我一域名咋就不安全啦

Let's Encrypt's 介绍

Let’s Encrypt is a free, automated, and open certificate authority (CA), run for the public’s benefit. It is a service provided by the Internet Security Research Group (ISRG).

Let's Encrypt's 是一个免费,自动化和开放的证书颁发机构(CA),为公众的利益而运行。它是由Internet Security Research Group(ISRG)提供的服务。

We give people the digital certificates they need in order to enable HTTPS (SSL/TLS) for websites, for free, in the most user-friendly way we can. We do this because we want to create a more secure and privacy-respecting Web.

我们免费为人们提供数字证书,以帮助他们为网站启用HTTPS,使得他们的网站能更加的安全,数据的隐私能更加有效地得到保护。

The key principles behind Let’s Encrypt are:

  • Free: Anyone who owns a domain name can use Let’s Encrypt to obtain a trusted certificate at zero cost.
  • Automatic: Software running on a web server can interact with Let’s Encrypt to painlessly obtain a certificate, securely configure it for use, and automatically take care of renewal.
  • Secure: Let’s Encrypt will serve as a platform for advancing TLS security best practices, both on the CA side and by helping site operators properly secure their servers.
  • Transparent: All certificates issued or revoked will be publicly recorded and available for anyone to inspect.
  • Open: The automatic issuance and renewal protocol will be published as an open standard that others can adopt.
  • Cooperative: Much like the underlying Internet protocols themselves, Let’s Encrypt is a joint effort to benefit the community, beyond the control of any one organization.

我们的主旨是:免费、自动化、安全、透明、开放、合作

Certbot

Certbot是Let's Encrypt CA(或任何其他讲ACME协议的CA)的全功能,可扩展的客户端,可以自动完成获取证书和配置Web服务器以使用它们的任务。此客户端在基于Unix的操作系统上运行。

安装

Certbot打包在EPEL(企业Linux的额外包)中。 要使用Certbot,必须先启用EPEL存储库。 在RHEL或Oracle Linux上,还必须启用可选通道。

yum -y install yum-utils
yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional

安装certbot的nginx版插件

yum install python2-certbot-nginx

自动识别nginx配置文件中的域名,一步步获取证书,并自动修改配置文件

certbot --nginx

如果不希望修改配置文件,而只是获取证书可以使用下面这个命令

certbot --nginx certonly

自动续期

可以将Certbot配置为在证书过期之前自动续订证书。 由于Let's Encrypt证书持续90天,因此最好利用此功能。 您可以通过运行以下命令来测试证书的自动续订:

certbot renew --dry-run

如果这看起来工作正常,您可以通过添加运行以下命令的cron作业或systemd计时器来安排自动续订:

certbot renew

如果您正在设置cron或systemd作业,我们建议每天运行两次(在您的证书到期或续订之前,它将不会执行任何操作,但定期运行它会使您的站点有机会保持在线状态 案例a由于某种原因,我们发生了加密启动的撤销。 请在一小时内随机选择续订任务。

一个示例cron作业可能看起来像这样,它将在每天中午和午夜运行:

0 0,12 * * * python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew 

引用

1.certbot on github
2.Certbot Installation Guide

相关文章
|
1月前
|
存储 算法 安全
ssl 证书名词解释--crt和pem
ssl 证书名词解释--crt和pem
64 0
|
1月前
|
Linux 应用服务中间件 网络安全
linux ssl 证书 --本地制作数字证书并进行程序的数字签名
linux ssl 证书 --本地制作数字证书并进行程序的数字签名
21 0
|
1月前
|
应用服务中间件 Linux 网络安全
CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本
CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本
17 0
|
16天前
|
存储 Ubuntu 应用服务中间件
【Nginx】centos和Ubuntu操作系统下载Nginx配置文件并启动Nginx服务详解
【Nginx】centos和Ubuntu操作系统下载Nginx配置文件并启动Nginx服务详解
22 1
|
4天前
|
存储 监控 安全
Elasticsearch 8.X 集群 SSL 证书到期了,怎么更换?
Elasticsearch 8.X 集群 SSL 证书到期了,怎么更换?
22 3
|
12天前
|
关系型数据库 MySQL 应用服务中间件
centos7在线安装jdk1.8+tomcat+mysql8+nginx+docker
现在,你已经成功在CentOS 7上安装了JDK 1.8、Tomcat、MySQL 8、Nginx和Docker。你可以根据需要配置和使用这些服务。请注意,安装和配置这些服务的详细设置取决于你的具体需求。
38 2
|
20天前
|
安全 应用服务中间件 网络安全
SSL原理、生成SSL密钥对、Nginx配置SSL
现在,你的Nginx虚拟主机应该已经配置了SSL,可以通过HTTPS安全访问。确保在生产环境中使用有效的SSL证书来保护通信的安全性。
30 0
|
29天前
|
Linux 网络安全 Python
解决方案:Centos7运行Django项目报错no module named _ssl
解决方案:Centos7运行Django项目报错no module named _ssl
21 0
|
29天前
|
应用服务中间件 Linux nginx
CentOS7安装Nginx
CentOS7安装Nginx
37 0
|
1月前
|
网络协议 应用服务中间件 Linux
centos7 Nginx Log日志统计分析 常用命令
centos7 Nginx Log日志统计分析 常用命令
152 2