【发布时间】:2017-06-24 23:43:42
【问题描述】:
我在运行 Nginx 的网络服务器上设置了 Letsencrypt SSL 证书。
http 到 https 重定向对于非 www 和 www 都可以正常工作。
直接去https://www.example.com 工作。
https非www不起作用,浏览器返回连接被拒绝。
所以:
http://example.com转https://www.example.com
http://www.example.com 到 https://www.example.com
工作
https://example.com 到 https://www.example.com
没用
我的网站配置是
server {
listen 80;
server_name example.com www.example.com;
return 301 https://www.example.com$request_uri;
}
server {
listen 443 ssl http2;
server_name example.com;
#ssl certs locations etc.
return 301 https://www.example.com$request_uri;
}
server {
listen 443 ssl http2;
server_name www.example.com;
#ssl certs locations etc.
#rest of main block
}
letsencrypt 证书是使用命令创建的(certbot-auto,因为服务器运行的是较旧的 linux 发行版):
certbot-auto certonly -n -a webroot --webroot-path=[path to webroot] -d example.com -d www.example.com --email foo@example.com --agree-tos
看过其他类似的问题后,nginx conf 应该可以工作。 据我了解,我创建证书的方式意味着 example.com 和 www.example.com 都有一个证书。
当我加载网站并查看证书时,两者都列在主题备用名称下。
【问题讨论】:
标签: nginx lets-encrypt