18143453325 在线咨询 在线咨询
18143453325 在线咨询
所在位置: 首页 > 营销资讯 > 网站运营 > 免费 https 证书(Let's Encrypt)申请与配置

免费 https 证书(Let's Encrypt)申请与配置

时间:2022-08-22 20:24:01 | 来源:网站运营

时间:2022-08-22 20:24:01 来源:网站运营

原文:免费 Https 证书(Let's Encrypt)申请与配置

之前要申请免费的 https 证书操作步骤相当麻烦,今天看到有人在讨论,就搜索了一下。发现现在申请步骤简单多了。


1. 下载 certbot

$ git clone https://github.com/certbot/certbot$ cd certbot$ ./certbot-auto --help解压打开执行就会有相关提示

2. 生成免费证书

./certbot-auto certonly --webroot --agree-tos -v -t --email 邮箱地址 -w 网站根目录 -d 网站域名./certbot-auto certonly --webroot --agree-tos -v -t --email keeliizhou@gmail.com -w /path/to/your/web/root -d note.crazy4code.com注意这里 默认会自动生成 /网站根目录/.well-known/acme-challenge,然后 shell 脚本会对应的访问 网站域名/.well-known/acme-challenge

比如:我的域名是note.crazy4code.com那我就得保证域名下面的.well-known/acme-challenge/目录是可访问的

如果返回正常就确认了你对这个网站的所有权,就能顺利生成

3. 获取证书

如果上面的步骤正常 shell 脚本会展示如下信息:

- Congratulations! Your certificate and chain have been saved at/etc/letsencrypt/live/网站域名/fullchain.pem...

4. 生成 dhparams

使用 openssl 工具生成 dhparams

openssl dhparam -out /etc/ssl/certs/dhparams.pem 2048

5. 配置 Nginx

打开 nginx server 配置文件加入如下设置:

listen 443ssl on;ssl_certificate /etc/letsencrypt/live/网站域名/fullchain.pem;ssl_certificate_key /etc/letsencrypt/live/网站域名/privkey.pem;ssl_dhparam /etc/ssl/certs/dhparams.pem;ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;ssl_ciphers HIGH:!aNULL:!MD5;然后重启 nginx 服务就可以了

6. 强制跳转 https

https 默认是监听 443 端口的,没开启 https 访问的话一般默认是 80 端口。如果你确定网站 80 端口上的站点都支持 https 的话加入下面的配件可以自动重定向到 https

server { listen 80; server_name your.domain.com; return 301 https://$server_name$request_uri;}

74
73
25
news

版权所有© 亿企邦 1997-2022 保留一切法律许可权利。

为了最佳展示效果,本站不支持IE9及以下版本的浏览器,建议您使用谷歌Chrome浏览器。 点击下载Chrome浏览器
关闭