来自请求的主机头被忽略?

我读了apache文档,但有很多东西,这在Debian中是不同的[lenny,5.0.6]。

Apache忽略浏览器给出的主机头:根据我的定义, http:// x或http:// x:81或http://x.mbg.local都被提供,但应该被阻止。 x的定义源于我的hosts文件[每个人都可以这样做]。 我是新来的新的Apache,但在我的IIS这符合预期。 所有浏览器的行为相同[所以没有浏览器头问题]。

我configuration了两个VirtualHosts,摘录如下:

NameVirtualHost hugo:80

DocumentRoot / usr / share / doc别名/ doc / / usr / share / doc /选项索引MultiViews FollowSymLinks允许来自192.168.24.0/24

另一个VirtualHostconfiguration为端口81。

我在我的主机文件在任何框,并添加新的名字x下的hugo的ip地址。 然后,x服务,虽然在Apache的主机头是胡戈! 每个来自互联网的用户都可以做到这一点!

我现在没有希望了。 有人帮我吗?

会非常好!

UPDATE

现在,我刚刚从httpd.conf中删除了所有内容,并创build了两个启用的站点以使事情变得更简单:

首先,对于nagios [只能用于这个:

  HTTP://雷神:81 

NameVirtualHost thor:81

 <VirtualHost thor:81> ServerName thor:81 ServerAlias thor:81 ServerPath /usr/share/nagios3 DocumentRoot /usr/share/nagios3 </VirtualHost> 

但它的答案

  HTTP://thor.mbg.local:81 

甚至上

  HTTP:// X:81 

也!

然后,一个testing服务器:

 NameVirtualHost thor.mbg.local:80

    
     ServerName thor.mbg.local
     ServerAlias thor.mbg.local
     DocumentRoot / var / www / default
    
    订单允许,拒绝
        全部允许
    
    

这也是答案

  HTTP:雷神/ 

  HTTP://thor.mbg.local/ 

这个完整的configuration被apache所接受。 我无法find默认值,这将覆盖configuration。

有没有可能的其他HTTP服务器软件,这使得这个权利? (我来自IIS,在这里工作。)

现在:明白了!

感谢所有的帮助! 我还没有认识到,所有的属性,如名称/ IP和端口必须匹配到处。 在我的情况下,回到默认主机发生了!

我从零开始创build了一个“玩debian”的虚拟机并完成了它。 如果有人会看到最终的定义,这里是:

在debians port.conf中,我现在有:

NameVirtualHost 192.168.26.92:80

b)在httpd.conf中:

 <VirtualHost 192.168.26.92:80> DocumentRoot /var/www/block <Directory /var/www/block> Options Indexes FollowSymLinks MultiViews AllowOverride None Order Allow,Deny Allow from All ##would just like to see, this is the end!!! </Directory> </VirtualHost> <VirtualHost 192.168.26.92:80> ServerName wl1 ServerAlias wl1 DocumentRoot /var/www/test80 <Directory /var/www/test80> Options Indexes FollowSymLinks MultiViews AllowOverride None Order Allow,Deny Allow from All </Directory> LogLevel debug ErrorLog /var/log/apache2/test80-error.log CustomLog /var/log/apache2/test80-access.log vhost_combined </VirtualHost> <VirtualHost 192.168.26.92:80> ServerName wl2 ServerAlias wl2 DocumentRoot /var/www/test81 <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/test81> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all </Directory> LogLevel info ErrorLog /var/log/apache2/error-test81.log CustomLog /var/log/apache2/test81-access.log vhost_combined </VirtualHost> 

对于一个初学debian的人来说,我觉得configuration文件太多是不好的,你会放弃概述。

非常感谢所有的帮助!

BR ++ mabra

在许多configuration中,可用虚拟服务器定义之一(通常是文件中的第一个)充当默认设置。 缺省值是Apache在请求标头与其中一个虚拟主机不匹配时所提供的服务。

如果这不能回答您的问题,请提供一个更完整的configuration示例,请求URL,提供的内容以及您期望提供的内容。


编辑

据我所知,在你的configuration中,当apache收到一个带有HTTP头Host:x的请求时,它看不到它应该做什么的定义。 它认为,无论什么绝望,我都会从第一个网站上提供一些东西,哦,看,这是一个托尔网站 – 我只是从那里提供的东西!

请参阅http://httpd.apache.org/docs/2.0/vhosts/details.html

该列表中的第一个虚拟主机(具有指定IP地址的configuration文件中的第一个虚拟主机)具有最高的优先级,并捕获对未知服务器名称或未包含主机:标题字段的请求的任何请求。

如果这让你困扰,build立一个虚拟主机为unknown.server.name,指向一个空目录,并build立一个自定义的404,说:“有人已经指出我们的服务器的IP地址的主机名没有安排与我们的networking,网站要为该主机名服务 – 抱歉!

你不需要使用不同的端口。 我认为这是你们混淆的根源。

基于名称的虚拟主机的最新文档(这是我想,你想要做的)是相当不错的:

http://httpd.apache.org/docs/current/vhosts/name-based.html