存档

文章标签 ‘VirtualHost’

How to use Name-Based Virtual Hosting to identify different SSL virtual hosts?

2010年2月21日 哈哈 没有评论

怎样用基于域名的虚拟主机来标识不同的ssl的虚拟主机呢?
奇了怪了
前面不是已经否定了这个可能性了吗
怎么还出来Howto的问题呢?
不是我不明白,这世界变化快
原来的ssl协议是不支持的
但自打tls出来
支持个叫SNI(Server Name Indication)的feature之后
做基于域名的ssl的虚拟主机已经不再是天方夜谭
让我们还以apache+mod_ssl为例来说明问题
我们先看官方文档怎么说的

It is possible, but only if using a 2.2.12 or later web server, built with 0.9.8j or later OpenSSL. This is because it requires a feature that only the most recent revisions of the SSL specification added, called Server Name Indication (SNI).

这一段是摘自于最新的apache官方文档
写的很明白
只要apache的版本大于等于2.2.12
OpenSSL的版本大于等于0.9.8j
就可以支持
顺手再写个ssl虚机的例子:

<VirtualHost 127.0.0.1:443>
    SSLEngine On
    ServerName sni.ssl.xxx.com:443
    DocumentRoot /var/www/htdocs/
    SSLCertificateChainFile /var/www/ssl/root.pem
    SSLCertificateFile /var/www/ssl/root.crt
    TransferLog /var/www/logs/access.log
</VirtualHost>

Why can’t I use SSL with name-based/non-IP-based virtual hosts?

2010年2月12日 哈哈 没有评论

以前用mod_ssl+apache配ssl服务器碰到过这个问题
别人直接用ip:443端口直接访问
就显示了缺省的https的站点
按照我们配http服务器的逻辑
肯定是想把443端口和某一个域名绑定起来用的
这样别人不知道域名就无法访问到真正的https站点内容
但是直接在apache里用

这样搞是不行的
系统总是只认第一个虚机
然后把所有https到443端口的访问都丢到里面
看了下(apache)官方的文档
里面是这样解释的:

Why can’t I use SSL with name-based/non-IP-based virtual hosts?
The reason is very technical, and a somewhat “chicken and egg” problem. The SSL protocol layer stays below the HTTP protocol layer and encapsulates HTTP. When an SSL connection (HTTPS) is established Apache/mod_ssl has to negotiate the SSL protocol parameters with the client. For this, mod_ssl has to consult the configuration of the virtual server (for instance it has to look for the cipher suite, the server certificate, etc.). But in order to go to the correct virtual server Apache has to know the Host HTTP header field. To do this, the HTTP request header has to be read. This cannot be done before the SSL handshake is finished, but the information is needed in order to complete the SSL handshake phase. Bingo!

金步国同学翻译如下:
为什么不能在基于域名的虚拟主机上使用SSL?
原因很技术化,有点类似于”鸡和蛋”的问题。SSL协议层位于HTTP协议层之下,HTTP协议是被封装在SSL协议中的,当一个SSL连接(HTTPS)请求到来的时候,Apache/mod_ssl必须和客户端协商SSL协议参数(握手),所以,mod_ssl必须查看虚拟主机的配置信息(例如允许使用哪些加密算法、服务器证书是哪个等等),然后才能完成SSL会话通道的建立;但另一方面,为了确切知道究竟应该查看哪个虚拟主机,Apache又必须知道HTTP请求头的Host字段的内容,而这在完成SSL握手之前是不可能知道的。

apache的LogLevel可以在虚机(virtual host)的设置里用

2009年6月15日 哈哈 没有评论

今天用到LogLevel于VirtualHost中了
查了文档确认了一下
特此记录