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证书 ...
随机推荐
- (转)一个简单的rest_framework demo
转发:https://www.cnblogs.com/fu-yong/p/9100559.html models.py 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 from ...
- 实验一linux 系统简介和实验二基本概念及操作
作业 zy e
- Ubuntu16.04下 编译安装 Tensorflow
安装bazel sudo ./bazel***.sh 输入bazel version 检查是否安装. 编译tensorflow 1)./configure 除了选择支持cuda是y,其余的都选择n. ...
- Alpha版会议总结
目前的进度: 实现了文字备忘的录入: 实现了提醒功能: 实现了可视化界面: 语音录入功能还没有完成: 界面相当粗糙: 遇到的问题: 语音录入按钮按下后没有反应,目前没有解决思路和方法. 原本的解屏功能 ...
- Oracle Form Builder
Oracle Form Builder 是Oracle的一个开发工具,可以针对Oracle公司的E-Business Suit的ERP系统开发的.对应的还有reports builder. Oracl ...
- 经验分享(Android开发)
以前对于Android开发一点了解都没有,当然,以前觉得是一件很高大上的事情,而且是我没有能力去做的工作,但是在这个小组合作开发Android后,我觉得我有了很大的进步,当然我的进步也是Android ...
- mvc学习-编辑提交需要注意-mvc重点
示例代码: // GET: /Movies/Edit/5 public ActionResult Edit(int? id) { if (id == null) { return new HttpSt ...
- 删除一个数字之后数列gcd最大
★实验任务 顾名思义,互质序列是满足序列元素的 gcd 为 1 的序列.比如[1,2,3], [4,7,8],都是互质序列.[3,6,9]不是互质序列.现在并不要求你找出一个互质 序列,那样太简单了! ...
- angularJS1笔记-(8)-内置指令
index.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset=&qu ...
- 前端切图相关ps技术
标签(空格分隔): 前端切图 复制图层到一个新的ps文件 对于单个图层 1.选中图层 2.CTRL+A全选 3.CTRL+C 4.CTRL+N新建文件,文件大小默认就可以(背景透明也在这个面板设置), ...