写在前面
本教程简要说明Nginx(LNMP)环境下快速注册Let’s Encrypt证书的方法并添加自动续期脚本。使用LNMP一键安装包的同学,Javen建议首先升级至LNMP1.3版本并把Nginx升级到1.9.8及以上,开启HTTP/2,注意Let’s Encrypt官方推荐首先升级Python27版本。
什么是Let’s Encrypt
The project aims to make encrypted connections in the World Wide Web the default case. By getting rid of payment, web server configuration, validation emails and dealing with expired certificates it is meant to significantly lower the complexity of setting up and maintaining TLS encryption.On a Linux web server, execution of only two commands is sufficient to set up HTTPS encryption, acquire and install certificates within 20 to 30 seconds.
Let’s Encrypt 是一个将于2015年末推出的数字证书认证机构,将通过旨在消除当前手动创建和安装证书的复杂过程的自动化流程,为安全网站提供免费的SSL/TLS证书。目前免费的证书有CloudFlare的免费SSL证书,也可以参考注册沃通免费SSL证书教程。
HTTPS现在已经是网站安全环境的必备条件,具有非常重要的意义。签发一个受到所有主流浏览器信任的证书就显得尤为重要。
Let’s Encrypt 是由互联网安全研究小组(ISRG,一个公益组织)提供的服务。主要赞助商包括电子前哨基金会,Mozilla基金会,Akamai以及思科。2015年4月9日,ISRG与Linux基金会宣布合作。
用以实现这一新的数字证书认证机构的协议被称为自动证书管理环境(ACME)。GitHub上有这一规范的草案,且提案的一个版本已作为一个Internet草案发布。
2015年10月19日, Let’s Encrypt已经得到了IdenTrust 的交叉签名,这意味着其证书现在已经可以被所有主流的浏览器所信任。
2015年12月3日,Let’s Encrypt正式公测。
Let’s Encrypt 宣称这一过程将十分简单、自动化并且免费。
Let’s Encrypt目前支持多域名证书。在申请的时候你可以输入你拥有的多个域名,比如我可以输入我拥有的两个域名bbs.okwoo.com、tieba.okwoo.com。但最多只能输入100个域名。通配型证书(比如*.okwoo.com)目前不被支持。
具体时间表:
The Let’s Encrypt project was started in late 2012 by two Mozilla employees, Josh Aas and Eric Rescorla. Internet Security Research Group, the company behind Let’s Encrypt, was incorporated in May of 2013. In June of 2013 a project involving the Electronic Frontier Foundation and the University of Michigan merged into the Let’s Encrypt project.
On September 14, 2015, Let’s Encrypt issued its first certificate, which was for the domain helloworld .letsencrypt .org. On the same day, ISRG submitted its root program applications to Mozilla, Microsoft, Google and Apple.
On October 19, 2015 the intermediate certificates became cross-signed by IdenTrust, causing all certificates issued by Let’s Encrypt to be trusted by all major browsers.
On November 12, 2015 Let’s Encrypt announced that general availability would be pushed back and that the first public beta will commence on December 3, 2015.
Nginx下快速安装Let’s Encrypt证书
首先在Linux服务器上安装Git:
1 |
Debian/Ubuntu: sudo apt-get install git |
1 |
CentOS: sudo yum install git |
1 |
Arch Linux: sudo pacman -S git |
然后,克隆Let’s Encrypt的Github repository:
1 2 |
git clone https://github.com/letsencrypt/letsencrypt cd letsencrypt |
开始配置:
我们需要暂时停止nginx,然后再次运行一次上面的命令:
1 |
service nginx stop |
#若需强制停止Nginx,强制停止命令
1 |
# pkill -9 nginx |
1 |
./letsencrypt-auto certonly --standalone -d okwoo.com -d www.okwoo.com -d bbs.okwoo.com -d tieba.okwoo.com |
-d后为想要申请证书的对应的子域名。多个子域名可以往后续加。当命令完成时,你会看到如下消息,表示你已经成功申请到了证书。证书和密钥都保存在/etc/letsencrypt/live/yourdomain目录下。
1 2 |
执行此命令后,如果提示 WARNING: Python 2.6 support is very experimental at present... |
那么你应该首先升级Python27版本。
界面会要求你输入一个邮箱地址,用来接收紧急通知或者找回密钥。点击“同意”服务条款,然后输入你的域名。Let’s Encrypt支持多域名证书,所以你可以输入多个域名,但不能超过100个。注意你输入的域名的IP地址必须要指向你现在的服务器。Let’s Encrypt会通过DNS验证你的域名是否与你的服务器IP对应。输入的第一个域名是Common Name,然后全部域名都会出现在Alternative Name栏目下。
你可能会看见如下错误,提示nginx进程已经在监听80端口:
1 2 3 4 5 6 7 8 |
IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at /etc/letsencrypt/live/yourdomain.com/fullchain.pem. Your cert will expire on 2016-03-06. To obtain a new version of the certificate in the future, simply run Let's Encrypt again. - If like Let's Encrypt, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le |
然后,启动nginx进程:
1 |
service nginx start |
最后,修改user/local/nginx/nginx.conf或user/local/nginx/conf/yourdomain.conf文件,添加证书文件:
1 2 |
ssl_certificate /etc/letsencrypt/live/okwoo.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/okwoo.com/privkey.pem; |
重启nginx:
1 |
service nginx restart |
然后访问你的域名,期待已久的SSL证书终于可以用了!既然开启了HTTPS,建议开启HSTS,这将更加安全。
为Let’s Encrypt证书续期
因为Let’s Encrypt的证书有效期只有90天,方便起见可以使用crontab来设置定时任务。
手动续期
1 2 |
cd letsencrypt ./letsencrypt-auto renew |
相关文章:
HTTPS加密简介以及Nginx安装 Let’s Encrypt 免费SSL/TLS证书
用了https后效果不太理想,很多地方不兼容,又换了回来。
无须担心,现在https正在普及。
一直想https,但技术不到又是虚拟主机,所以就没弄了~~
./letsencrypt-auto –renew certonly –email youmail@gmail.com -d youmail.com
一步到位
学习了。
博主,那个自动脚本更新不了呀
提示:{
usage:
letsencrypt-auto [SUBCOMMAND] [options] [-d domain] [-d domain] …
Certbot can obtain and install HTTPS/TLS/SSL certificates. By default,
it will attempt to use a webserver both for obtaining and installing the
cert. Major SUBCOMMANDS are:
(default) run Obtain & install a cert in your current webserver
certonly Obtain cert, but do not install it (aka “auth”)
install Install a previously obtained cert in a server
renew Renew previously obtained certs that are near expiry
revoke Revoke a previously obtained certificate
register Perform tasks related to registering with the CA
rollback Rollback server configuration changes made during install
config_changes Show changes made to server config during installation
plugins Display information about installed plugins
letsencrypt: error: ambiguous option: –renew could match –renew-by-default, –renew-hook
}
可能是官方更新了吧,我都是手動更新了。
手握VPS的文科生表示看不太懂~
我也算半個文科生,文理不分家嘛
等我的SSL到期了也试试。
我也开启用这个了。不过还是有一些问题没有解决。必入字体是360的,不提供https。看看我的http://shanglei.net还有ssl方面的那些问题。求指点。
上ssl就要全站,还在考虑中。。。
可惜了,我买的虚拟主机不支持SSL证书…
没关系。慢慢来。
博主动作这么快,先用上了
不算快,赶个中上游。
以后 HTTPS 是趋势,HTTP 慢慢的会被淘汰掉。之前一直关注这个,但是由于没有自己的服务器,所以一直没能使用。文章写的不错,赞一个!
感谢支持
啥意思?根域不能HTTPS呗?
能,但暂不支持通配。
噢,那不错。
这个内测的时候就用上了,这个比一般便宜的证书兼容性还要好呢!
公益性质的证书普及程度大,加之由多家权威组织发起,并取得著名签发机构的认证,必然兼容性良好而且值得信赖!
自从ng支持h2.0之后貌似好多博客也使用了啊!我的也在上个月开启了。
是的,速度更快嘛!
尝试过了,建议直接使用github上面的acme-tiny,可以大大缩短时间。
这个大神写的包我也看见了,我的这个只是适合喜欢走流程的初学少年。
好详细的教程!
感谢来加人气,呵呵
么么哒
呵呵
写了那么多 ,可惜看不懂,呵呵
没事,写给需要的人
留下脚印
感谢支持