我的网站一切看上去都很好https://bejebeje.com
。
我想要同样的https://www.bejebeje.com
。
该网站托管在带有 nginx 的 Ubuntu VPS 上,对于证书我使用的是 Certbot。
这是我所做的。对于我的网站配置,我首先进行的是:
server {
server_name www.bejebeje.com bejebeje.com;
location / {
proxy_pass http://localhost:5010;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
然后我运行certbot --nginx
并将我的文件更新.conf
为:
server {
server_name www.bejebeje.com bejebeje.com;
location / {
proxy_pass http://localhost:5010;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/bejebeje.com-0001/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/bejebeje.com-0001/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = bejebeje.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name www.bejebeje.com bejebeje.com;
listen 80;
return 404; # managed by Certbot
}
Certbot 是不是出了什么问题?因为上述情况,即使重新加载 nginx 配置后,当我导航到https://www.bejebeje.com
答案1
您的证书对 无效www.bejebeje.com
,只对 bejebeje.com 有效。您可能忘记在 certbot 命令中添加-d www.bejebeje.com
选项。另外,您的证书不是通配符证书。因此,为了解决此问题,请添加www.bejebeje.com
certbot。