letsencrypt 生成 SSL 证书
- 事先配置好访问域名解析
- 在nginx 对应虚拟主机添加一个验证区域:
配置 nginx
server {
listen 80;
...
location ~ /.well-known {
root /data/web; # 目录存在即可
allow all;
}
...
}
生成 SSL
git clone https://.com/letsencrypt/letsencrypt
cd letsencrypt
./letsencrypt-auto certonly
- 选择使用: webroot 进行验证
一劳永逸
letsencrypt 证书有效期为3个月, 其生成证书路径在: /etc/letsencrypt/live/<domain>/
下, 证书名称为 fullchain.pem
, 私钥为 privatekey.pem
可以做一个软连接:
ln -sv /usr/local/openresty/nginx/conf/ssl/<pem_name> -> /etc/letsencrypt/live/kdax.hardlink.me/fullchain.pem
ln -sv /usr/local/openresty/nginx/conf/ssl/<key_name> -> /etc/letsencrypt/live/kdax.hardlink.me/privkey.pem