我有一个虚拟主机的debian框中configurationApache2。 我有几个域指向该框的IP地址。 虚拟主机configuration的域完美地工作。 但是如果我在浏览器中input一个指向这个盒子但是没有configuration虚拟主机的域名,我就可以到达一个盒子中另一个域名的随机虚拟主机。 不是一个随机的,而是一个虚拟主机(总是一样的),但我不知道为什么是这样。 正确的是,没有configuration为虚拟主机的域名会返回一个主机名称错误,对不对?
有人知道如何解决这个问题吗?
我的一个虚拟主机configuration文件:
<VirtualHost *:80> ServerAdmin [email protected] ServerName dl.domain.com DocumentRoot /var/www/dl.domain.com/public_html/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/dl.domain.com/public_html/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost>
我的apache2.conf
http://www.speedyshare.com/files/29107024/apache2.conf
谢谢您的帮助
configuration示例:
NameVirtualHost *:80 <VirtualHost *:80> ServerName www.domain.tld DocumentRoot /www/domain </VirtualHost> <VirtualHost *:80> ServerName www.otherdomain.tld DocumentRoot /www/otherdomain </VirtualHost>
定义的第一个虚拟主机将充当默认主机。
http://httpd.apache.org/docs/2.2/vhosts/name-based.html#using
如果您希望为不匹配任何特定虚拟主机的请求提供特殊configuration,只需将该configuration放在一个容器中,并首先将其列在configuration文件中。
“正确的是,未configuration为虚拟主机的域名会返回主机名称错误,对吗?”
如果你真的想要这种行为只是创build虚拟主机,把它放在所有其他VirtualHost条目之前,并指向空的文件夹。 没有文件服务它会给你403错误。
为了帮助debugging像这样运行的“apache2ctl -s”[1]将显示apache如何匹配虚拟主机。
[1]:在某些发行版中,apache2ctl可能被命名为apachectl