我正在使用 nginx 通过与 SSL 的本地连接为我的 Nextcloud 实例提供服务(在这种情况下,域被调用nextclowd.raspi.local并且它使用的是自签名证书)。
现在我想通过 DDNS 域访问它,我也想用 SSL 加密(我已经为该域生成了 Let's Encrypt 证书)。
但是现在我在使用这两个证书时遇到了问题。我也可以将 DDNS 证书用于我的本地连接,但这总是向我发出警告,因为证书与域不匹配。
我还想避免定义两个 vhost 条目(因为配置冗余)。我也读过关于 SNI 的东西,但据我所知,这不是我想要的。
是否可以让 nginx 根据在同一虚拟主机上访问的域选择正确的 SSL 证书?
这是我当前的 vhost 文件以供参考:
server {
listen 80;
server_name nextclowd.raspi.local mydomain.ddns.net;
# enforce https
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name nextclowd.raspi.local mydomain.ddns.net;
# My self-signed SSL certificate
#ssl_certificate /etc/nginx/ssl/server.crt;
#ssl_certificate_key /etc/nginx/ssl/server.key;
# My Let's Encrypt SSL certificate
ssl_certificate /etc/letsencrypt/live/mydomain.ddns.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mydomain.ddns.net/privkey.pem;
# Add headers to serve security …Run Code Online (Sandbox Code Playgroud) nginx ×1