通过Let’s Encrypt申请免费SSL证书方法
Let’s Encrypt简介
Let’s Encrypt作为一个公共且免费SSL的项目逐渐被广大用户传播和使用,是由Mozilla、Cisco、Akamai、IdenTrust、EFF等组织人员发起,主要的目的也是为了推进网站从HTTP向HTTPS过度的进程,目前已经有越来越多的商家加入和赞助支持。
Let’s Encrypt作为一个公共且免费SSL的项目逐渐被广大用户传播和使用,是由Mozilla、Cisco、Akamai、IdenTrust、EFF等组织人员发起,主要的目的也是为了推进网站从HTTP向HTTPS过度的进程,目前已经有越来越多的商家加入和赞助支持。
acme.sh 实现了 acme 协议, 可以从 let‘s encrypt 生成免费的证书.
安装acme.sh
推荐使用root用户安装
sudo su root
安装命令
curl https://get.acme.sh | sh
生成ssl证书
使用webroot方式
acme.sh –issue -d blog.lomot.cn –webroot /var/www/blog.lomot.cn/
或者可以使用nginx方式,具体还有其他的方法参考acme.sh项目的github
acme.sh –issue -d blog.lomot.cn –nginx
copy证书
acme.sh –installcert -d blog.lomot.cn –key-file /etc/nginx/ssl/blog.lomot.cn.key –fullchain-file /etc/nginx/ssl/blog.lomot.cn.cer –reloadcmd “service nginx force-reload”
应用证书
这里只给出nginx的方法:
例如网址是m.bishuqi.com 在/etc/nginx/nginx.conf
中添加如下
- server {
- listen 80;
- server_name m.bishuqi.com;
- rewrite ^(.*)$ https://$host$1 permanent;
- }
- server {
- listen 443;
- server_name m.bishuqi.com;
- ssl on;
- ssl_certificate /etc/nginx/ssl/m.bishuqi.com.cer;
- ssl_certificate_key /etc/nginx/ssl/m.bishuqi.com.key;
- ssl_session_timeout 5m;
- ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
- ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
- ssl_prefer_server_ciphers on;
- location / {
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header Host $http_host;
- proxy_pass http://localhost:3000;
- proxy_set_header REMOTE-HOST $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- }
- }
复制代码
很多集成环境搭建工具,虚拟机设置时都集成了Let’s encrypt SSL证书加密。比如Oneinstack-一键PHP/JAVA安装工具