Nginx Configuration 免费HTTPS加密证书
实验环境:CentOS Linux release 7.3.1611 (Core)
内核版本:Linux version 3.10.0-514.el7.x86_64
Nginx版本: Nginx-1.13.0
Let’s Encrypt是一个免费的、自动化、开放的证书颁发机构。由Mozilla、Cisco、Chrome、facebook、Akamai等众多公司和机构发起的,其安全稳定及其可靠。具体信息可以去letsencrypt官方网站了解详情。
今天我们就充分利用Lets Encrypt让你的网站实现https加密。
官网:https://letsencrypt.org/
1.安装certbot及源扩展包
$ yum install -y epel-release
Certbot是Let’s Encrypt官方指定推荐的客户端。通过 Certbot,你可以自动化部署 Let’s Encrypt SSL证书,以便为网站加上HTTPS加密支持。
$ yum install certbot
$ certbot certonly
Saving debug log to /var/log/letsencrypt/letsencrypt.log
How would you like to authenticate with the ACME CA?
//你是希望如何使用ACME CA进行身份验证?
-------------------------------------------------------------------------------
1: Place files in webroot directory (webroot)
//将文件放在webroot目录
2: Spin up a temporary webserver (standalone)
//使用临时Web服务器(独立目录)
-------------------------------------------------------------------------------
Select the appropriate number [1-2] then [enter] (press 'c' to cancel):1 【选择1回车】
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel):su@renwole.com【输入您的邮箱地址,用于紧急更新和安全通知】
Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org
-------------------------------------------------------------------------------
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf. You must agree
in order to register with the ACME server at
https://acme-v01.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(A)gree/(C)ancel: A【选择A回车同意服务条款,C为拒绝】
-------------------------------------------------------------------------------
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about EFF and
our work to encrypt the web, protect its users and defend digital rights.
-------------------------------------------------------------------------------
(Y)es/(N)o:Y【您是否愿意分享您的电子邮件地址,建议选择Y回车】
Please enter in your domain name(s) (comma and/or space separated) (Enter 'c'
to cancel): blog.renwole.com【输入域名回车】
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for blog.renwole.com
Select the webroot for blog.renwole.com:
-------------------------------------------------------------------------------
1: Enter a new webroot
//输入网站绝对路径
-------------------------------------------------------------------------------
Press 1 [enter] to confirm the selection (press 'c' to cancel):1【选择数字1回车】
Input the webroot for blog.renwole.com: (Enter 'c' to cancel):/home/www/blog.renwole.com【输入网站所在绝对路径回车】
Waiting for verification...
Waiting for verification...
Cleaning up challenges
Generating key (2048 bits): /etc/letsencrypt/keys/0001_key-certbot.pem
Creating CSR: /etc/letsencrypt/csr/0001_csr-certbot.pem
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at
/etc/letsencrypt/live/blog.renwole.com/fullchain.pem. Your cert
will expire on 2017-08-09. To obtain a new or tweaked version of
this certificate in the future, simply run certbot again. To
non-interactively renew *all* of your certificates, run "certbot
renew"
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF:
恭喜!您的SSL证书和密钥链接已保存,你的证书将于2017-08-09到期。
注意:这里需要说明,在生成证书之前,你必须保证nginx 443端口是运行状态,否则会生成证书失败。
2.自动续订
Certbot可以配置为在证书过期之前自动更新证书。由于Let’s Encrypt SSL证书有效期时间为90天,所以建议您利用此功能。您可以通过运行以下命令来测试证书的自动续订:
$ sudo certbot --nginx certonly
如果以上正常工作,你可以通过添加运行以下操作的cron或systemd定时任务安排自动更新:
certbot renew
我们写一个自动执行脚本,建议每小时执行一次:
$ sudo crontab -e
添加以下内容:
0 */6 * * * /usr/bin/certbot renew --quiet && /bin/systemctl restart nginx
保存并退出!
通过命令查看是否添加成功:
$ crontab -l
0 */6 * * * /usr/bin/certbot renew --quiet && /bin/systemctl restart nginx
重启crontab
$ systemctl status crond.service
$ systemctl restart crond.service
通过命令观察 crontab 是否执行:
$ tail -f /var/log/cron
证书是否续订成功,可以通过以下命令管理查看证书信息:
$ certbot certificates
更多Certbot命令请参阅官方文档 https://certbot.eff.org/docs/
3.配置nginx.conf
接下来修改Nginx配置文件,修改sever段,去掉相应注释,将生成的SSL证书填写到ssl_certificate后面,将生成的密钥填写到ssl_certificate_key后面,保存并重启nginx服务器即可。
# vi /usr/local/nginx/conf/nginx.conf
server {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/blog.renwole.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/blog.renwole.com/privkey.pem;
# ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
}
使用谷歌浏览器访问https://blog.renwole.com/可以看到绿色的安全小锁图标,说明网站已经https加密成功。
Nginx Configuration 免费HTTPS加密证书的更多相关文章
- nginx安装Lets Encrypt SSL免费HTTPS加密证书
Linux Nginx网站:Certbot安装配置Lets Encrypt SSL免费HTTPS加密证书 原文地址:https://renwole.com/archives/157 实验环境:Cent ...
- HTTPS加密证书流程(2)
目录 一:HTTPS加密证书流程 二:证书对比 三:自签证书 1.(lb服务器负载均衡代理) 2.(创建CA证书 创建密码) 3.生成自签证书(公钥),同时去掉私钥的密码(Enter) 四:证书内容解 ...
- mkcert本地 HTTPS 加密证书生成工具
软件介绍: mkcert 是一个生成本地 HTTPS 加密证书的工具,一个命令就可以生成证书,不需要任何配置. 下载地址: https://github.com/FiloSottile/mkcert/ ...
- NGINX之——配置HTTPS加密反向代理訪问–自签CA
转载请注明出处:http://blog.csdn.net/l1028386804/article/details/46695495 出于公司内部訪问考虑,採用的CA是本机Openssl自签名生成的,因 ...
- 给网站添加免费Https SSL证书
基于阿里云的云盾证书服务,系统是centos6.8,web服务器是nginx1.8.0,简单记录下踩坑情况. 申请证书 登录阿里云控制台→安全(云盾)→证书服务→购买证书(https://common ...
- HTTPS加密证书(1)
目录 一:HTTPS 1.HTTPS简介 二:模拟网站劫持 1.正常的页面(web01) 2.文件增加权限 3.编写文件网址配置 4.网址测试 三:安装鲨鱼鳍(抓取数据包) 四:(网站劫持)lb代理 ...
- 超详细网站博客域名和二级域名、子域名升级HTTPS免费申请SSL证书配置nginx指南
随着互联网的飞速发展,我们的工作生活已经离不开互联网,HTTP虽然使用极为广泛, 但是存在不小的安全缺陷, 主要是其数据的明文传送和消息完整性检测的缺乏, 而这两点恰好是网络支付,网络交易等网站应用中 ...
- Nginx安装SSL证书,开启HTTPS加密
效果就是访问博客的时候出现一把小绿锁,更加安(好)全(看). 实现步骤如下: 申请SSL证书 阿里云可以申请一年的免费证书,下载到本地 上传证书到服务器 scp [文件名] root@[ip地址]:/ ...
- 十大免费SSL证书:网站免费添加HTTPS加密
SSL证书,用于加密HTTP协议,也就是HTTPS.随着淘宝.百度等网站纷纷实现全站Https加密访问,搜索引擎对于Https更加友好,加上互联网上越来越多的人重视隐私安全,站长们给网站添加SSL证书 ...
随机推荐
- 苏宁笔试:UML类图中的关系
1. 依赖 2. 关联 3. 聚合 4. 组合 5. 泛化 6. 实现
- js格式化json字符串和json对象
1,格式化json对象 var json = {"@odata.context":"$metadata#AddTableOne_466281s","v ...
- TeamWork#3,Week5,The First Meeting of Our Team
sixsix第一次会议记录 [会议时间]2014年10月23日星期四19:00-20:00 [会议形式]小组讨论 [会议地点]5号公寓 [会议主持]高雅智 [会议记录]张志浩 会议整体流程 一.签到 ...
- c# 写文件注意问题及用例展示
以txt写string举例,正确代码如下: private void xie() { FileStream fs = new FileStream("1.txt", FileMod ...
- Sprint8
进展:添加事件主界面实现之后,实现事件添加部分代码的编写,进行设置事件提醒,选择时间.
- GITHUB随笔 15-5月 junit
junit 是用来做单元测试的一个工具 测试是一个持续的过程.也就是说测试贯穿与开发的整个过程中,单元测试尤其适合于迭代增量式的开发过程. @ignore: 该元数据标记的测试方法在测试中会被忽 ...
- 【贪心算法】POJ-1017
一.题目 Description A factory produces products packed in square packets of the same height h and of th ...
- 网桥 以及 IEEE802.1D 生成树协议
(一)网桥 网桥是一个layer 2设备,能够连接两个不同的网段. 如图
- WinForm中DataGridView的快速查找及将指定行显示到第一行
/// <summary> /// 快速在已绑定的列表查询车辆 /// </summary> /// <param name="sender"> ...
- Three.js入门篇(一)创建一个场景
上一面讲述了向场景中添加物体对象.这一篇准备把每个功能点细细的讲述一遍,一方面是为了加深自己的理解.另一方面希望能够 帮助到有需要的人. 一.在学习WEBGL的时候,你应该先了解要创建一个WebGL程 ...