Apache 命名的虚拟主机未捕获应发送给它的请求

发布于 2024-12-13 04:17:33 字数 1698 浏览 2 评论 0原文

我有一个 Apache 服务器,上面有一组基于名称的虚拟主机。请求通过 Apache 反向代理发送到服务器,该代理将对这些站点名称的所有请求转发到后端服务器上的端口 80。虽然这些站点中的大多数似乎工作正常,但其中一个虚拟主机无法接收对其指定站点名称的请求,而这些请求则由默认虚拟主机提供服务。

这是有问题的主机的配置:

<VirtualHost *:80>
   ServerName www.dev.awesome.ac.nz
   ServerAdmin [email protected]

   ErrorLog logs/awesomeacnz.error.log
   CustomLog logs/awesomeacnz.access.log common

   Alias / /var/www/html/awesomeacnz/
</VirtualHost>

这是 Apache 虚拟主机诊断的输出:

[aful018@wprappdev01 ~]$ sudo /usr/sbin/apachectl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443          wprappdev01.its.auckland.ac.nz (/etc/httpd/conf.d/ssl.conf:74)
*:80                   is a NameVirtualHost
     default server asblog.auckland.ac.nz (/etc/httpd/conf.d/academicservices.conf:1)
     port 80 namevhost asblog.auckland.ac.nz (/etc/httpd/conf.d/academicservices.conf:1)
     port 80 namevhost www.dev.awesome.ac.nz (/etc/httpd/conf.d/awesomeacnz.conf:1)
     port 80 namevhost www.dev.auckland.ac.nz (/etc/httpd/conf.d/insideword.conf:1)
     port 80 namevhost spearblog.dev.auckland.ac.nz (/etc/httpd/conf.d/spear.conf:1)
     port 80 namevhost wordpress-theme.dev.auckland.ac.nz (/etc/httpd/conf.d/theme-dev.conf:1)
Syntax OK

我在上面看不到任何表明存在问题的内容,但是当我在 www.dev.awesome.ac.nz 上发送任何内容的请求时该请求由 asblog.auckland.ac.nz 的虚拟主机提供服务,如您在上面看到的,它是默认主机。

有谁知道为什么上面定义的虚拟主机不会匹配该站点的请求? httpd.conf 中的 NameVirtualHost 指令设置为 *:80,同一服务器上其他类似(不相同)配置的站点工作正常。

服务器是在 Red Hat EL 6.1 上运行的 apache 2.2.15。

I have an Apache server with a group of name-based virtual hosts on it. Requests are sent to the server via an Apache reverse proxy, which forwards all requests for these site names to port 80 on the backend server. While most of these sites appear to be working fine, one vhost is failing to pick up requests for its designated site name, and these are instead being served by the default vhost.

Here's the configuration for the problematic host:

<VirtualHost *:80>
   ServerName www.dev.awesome.ac.nz
   ServerAdmin [email protected]

   ErrorLog logs/awesomeacnz.error.log
   CustomLog logs/awesomeacnz.access.log common

   Alias / /var/www/html/awesomeacnz/
</VirtualHost>

And here's the output of the Apache vhost diagnostic:

[aful018@wprappdev01 ~]$ sudo /usr/sbin/apachectl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443          wprappdev01.its.auckland.ac.nz (/etc/httpd/conf.d/ssl.conf:74)
*:80                   is a NameVirtualHost
     default server asblog.auckland.ac.nz (/etc/httpd/conf.d/academicservices.conf:1)
     port 80 namevhost asblog.auckland.ac.nz (/etc/httpd/conf.d/academicservices.conf:1)
     port 80 namevhost www.dev.awesome.ac.nz (/etc/httpd/conf.d/awesomeacnz.conf:1)
     port 80 namevhost www.dev.auckland.ac.nz (/etc/httpd/conf.d/insideword.conf:1)
     port 80 namevhost spearblog.dev.auckland.ac.nz (/etc/httpd/conf.d/spear.conf:1)
     port 80 namevhost wordpress-theme.dev.auckland.ac.nz (/etc/httpd/conf.d/theme-dev.conf:1)
Syntax OK

I can't see anything in the above that suggests a problem, but when I send a request for anything on www.dev.awesome.ac.nz the request is served by the vhost for asblog.auckland.ac.nz, which as you can see above is the default host.

Does anyone know why the vhost defined above would not be matching requests for that site? The NameVirtualHost directive in httpd.conf is set to *:80, and other similarly- (not identically-) configured sites on the same server are working fine.

The server is apache 2.2.15 running on Red Hat EL 6.1.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文