在Linux系统中使用Certbot为Nginx安装SSL证书并进行配置,通常遵循以下步骤:
sudo yum install epel-release
sudo yum install certbot
location
块,以便Certbot可以通过Webroot验证方式获取证书。例如:location ^~ /.well-known/acme-challenge/ {
default_type "text/plain";
root /usr/share/nginx/html;
}
location = /.well-known/acme-challenge/ {
return 404;
}
sudo service nginx reload
sudo certbot certonly --webroot -w /usr/share/nginx/html/ -d your.domain.com
your.domain.com
为你的实际域名。server {
listen 443 ssl;
listen [::]:443 ssl ipv6only=on;
ssl_certificate /etc/letsencrypt/live/your.domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your.domain.com/privkey.pem;
# 其他SSL设置...
}
sudo service nginx reload
https://your.domain.com
,如果配置正确,应该能看到安全的连接。具体操作可能会根据你的系统环境和Nginx版本略有不同。如果遇到问题,可以查看Certbot的日志文件或者搜索具体的错误信息来解决。
本文来自博客园,作者:dashery,转载请注明原文链接:https://www.cnblogs.com/ydswin/p/18242606
参与评论
手机查看
返回顶部