Nginx
https 在 www.site.com 和 site.com
我的網站在
https://bejebeje.com
.我想要同樣的
https://www.bejebeje.com
。對於我使用 Certbot 的證書,該站點託管在帶有 nginx 的 Ubuntu VPS 上。
這就是我所做的。對於我的站點配置,我從以下內容開始:
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
您的證書對 無效
www.bejebeje.com
,但僅對 bejebeje.com 有效。您可能忘記在-d www.bejebeje.com
您的 certbot 命令中添加選項。此外,您的證書不是萬用字元證書。因此,為了解決此問題,請添加www.bejebeje.com
certbot。