首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何禁用https对特定虚拟主机的访问?

如何禁用https对特定虚拟主机的访问?
EN

Server Fault用户
提问于 2013-02-23 05:20:16
回答 3查看 43.3K关注 0票数 10

好的,我有一个Apache服务器设置了以下指令:

NameVirtualHost *:80

代码语言:javascript
运行
复制
<VirtualHost *:80>  
ServerName example1.com  
ServerAlias www.example1.com  
DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost *:80>
ServerName example2.com
ServerAlias *.example2.com
DocumentRoot /var/www/example2
</VirtualHost>

<VirtualHost example1.com:443>
DocumentRoot /var/www/html
ServerName example1.com:443
SSLEngine on
...
</VirtualHosts>

因此example1.com具有SSL支持,可以通过http:// example1.com或https:// example1.com访问。但是,当我在浏览器中访问https:// example2.com时,这会产生意外的副作用,即显示https:// example1.com。我想要做的基本上是禁用https:// example2.com,或者将其重新定向到http:// example2.com,这样当我访问它时就不会收到警告和错误的站点。

EN

回答 3

Server Fault用户

回答已采纳

发布于 2013-02-23 09:06:41

您将无法避免收到警告,除非example1和example2位于不同的IP地址上,或者您获得了包含两个名称的SSL证书--直到建立了SSL连接之后才能发生错误页或重定向。

话虽如此,这样的东西应该能发挥作用:

代码语言:javascript
运行
复制
NameVirtualHost *:443
<VirtualHost *:443>
  ServerName example1.com
  SSLEngine on
  #...
</VirtualHost>
<VirtualHost *:443>
  ServerName example2.com
  SSLEngine on
  # same certificate config here as on example1, unless you're wanting to use TLS SNI
  # then, let's redirect the user to non-SSL
  Redirect permanent / http://example2.com/
</VirtualHost>
票数 6
EN

Server Fault用户

发布于 2013-02-23 07:35:43

我认为你不应该把:443放在ServerName example1.com上:443

这些应该是正确的配置

代码语言:javascript
运行
复制
<VirtualHost example1.com:443> //change example1.com to ip address is a good habit
DocumentRoot /var/www/html
ServerName example1.com
SSLEngine on
...
</VirtualHosts>
票数 0
EN

Server Fault用户

发布于 2013-02-26 12:24:06

您需要有服务器名称指示(SNI)来完成这一任务。有关详细信息,请参阅链接:http://wiki.apache.org/httpd/NameBasedSSLVHostsWithSNI

票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/481738

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档