Che*_*ing 8 lets-encrypt certbot
我正在添加https对我们服务器的支持.添加Let的加密支持时,如何才能阻止Nginx?
将此块添加到您的server配置中(根据您的服务器配置,您可以使用以外的其他路径/var/www/html):
location ~ /.well-known {
root /var/www/html;
allow all;
}
Run Code Online (Sandbox Code Playgroud)
重新加载nginx,如下运行certbot:
certbot certonly -a webroot --webroot-path=/var/www/html -d yourdomain.example
Run Code Online (Sandbox Code Playgroud)
将生成的证书应用于您的server配置
ssl_certificate /etc/letsencrypt/live/yourdomain.example/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.example/privkey.pem;
Run Code Online (Sandbox Code Playgroud)
确保将服务器设置配置为使用ssl在端口443上运行:
listen 443 ssl;
Run Code Online (Sandbox Code Playgroud)
再次重新加载nginx。在两次重载之间,您可以通过运行来确保配置是否没有语法错误nginx -t。
您可以使用 docker 来实现这一点。hub.docker 上的链接
例如:
创建 certbot.sh
为此,您必须在 CLI 中运行:
touch certbot.sh && chmod +x ./certbot.sh
Run Code Online (Sandbox Code Playgroud)
写入文件:
#!/usr/bin/env bash
docker run --rm -v /etc/letsencrypt:/etc/letsencrypt -v /var/lib/letsencrypt:/var/lib/letsencrypt certbot/certbot "$@"
Run Code Online (Sandbox Code Playgroud)
并像这样运行:
./certbot.sh --webroot -w /var/www/example -d example.com -d www.example.com -w /var/www/thing -d thing.is -d m.thing.is
Run Code Online (Sandbox Code Playgroud)
或者
./certbot.sh renew
Run Code Online (Sandbox Code Playgroud)
并且您可以在 crontab 中添加调用此方法来更新
0 0 1 * * /<PATH_TO_FILE>/certbot.sh renew
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1882 次 |
| 最近记录: |