没有 ssl 证书的域重定向到不同的 ssl 域

编程入门 行业动态 更新时间:2024-10-07 07:34:21
本文介绍了没有 ssl 证书的域重定向到不同的 ssl 域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在 Digital Ocean 液滴上设置了两个域(使用 nginx).我已经在其中一个(域 1)中安装了 SSL 证书,并且该证书一切正常.第二个域 (domain2) 不需要 SSL 证书,但是如果我尝试访问 domain2 会向我显示domain1 的内容并给我一个证书错误(此页面不安全).

I have two domains set up on a Digital Ocean droplet (with nginx). I've installed a SSL certificate in one of them (domain1) and everything is fine with that one. The second domain (domain2), does not require a SSL certificate but if I try to access domain2 is showing me the content of domain1 and giving me a certificate error (This page is not secure).

我了解证书错误,但我不希望域 1 的内容显示在 domain2

I understand the certificate error, but I don't want the contents of domain1 being displayed in domain2

是配置问题吗?

推荐答案

nginx 总是有一个 默认服务器,如果 server_name 不匹配.如果您只有一个带有 listen 443 的服务器块,那么无论服务器名称如何,这都是所有 https 连接的隐式默认服务器.

nginx always has a default server, the one that is used if the server_name does not match. If you only have one server block with listen 443, then that is the implicit default server for all https connections irrespective of server name.

您需要为 https 连接设置一个明确的 catch-all 服务器,或者将 listen 443 ssl 添加到现有的 server 块充当 catch-all 服务器.

You will need to set up an explicit catch-all server for https connections, or add listen 443 ssl to an existing server block to act as the catch-all server.

您可以重复使用相同的证书文件,如果有人尝试使用它,您将继续收到证书错误,但至少您的其他域不会暴露.

You can reuse the same certificate file and you will continue to get certificate errors if anyone attempts to use it, but at least your other domains will not be exposed.

例如:

ssl_certificate /path/to/crt; ssl_certificate_key /path/to/key; server { listen 443 ssl; server_name domain1; ... } server { listen 443 ssl default_server; return 403; }

请参阅本文档和本文档了解更多信息.

See this document and this document for more.

更多推荐

没有 ssl 证书的域重定向到不同的 ssl 域

本文发布于:2023-11-02 07:01:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551687.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   证书   ssl

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!