请求不会选择 Apache2 000-Default VHost

Apache2 000-Default VHost won't be choosen by a Request

我有一台安装了 Debian GNU/Linux 9 (stretch) 和 Apache/2.4.25 (Debian) 的 Linux 服务器。我想在我的服务器上托管多个网站。例如,一个主要网站和 2-3 个供朋友使用的较小网站。当请求到达未在 VHosts 中配置的 Web 服务器(例如 IP 地址)时,我还希望显示默认页面。例如欢迎来到 bla bla bla。

我想提一下,每次更改后我都会重新加载网络服务器并且所有文件权限都是正确的。

我的配置:

已启用站点:

000-default.conf:

<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

ServerAdmin admin@vaorra.net
DocumentRoot /websites/www/

<Directory /websites/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
            Require all granted
</Directory>

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

露天-seuzach.ch.conf:

<VirtualHost openair-seuzach.ch:80>

    ServerName openair-seuzach.ch

    ServerAdmin admin@vaorra.net

    DocumentRoot /websites/openair-seuzach.ch/
    <Directory /websites/openair-seuzach.ch/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
            Require all granted
    </Directory>

 </VirtualHost>

vaorra.net.conf:

<VirtualHost vaorra.net:80>

    ServerName vaorra.net

    ServerAdmin admin@vaorra.net

    DocumentRoot /websites/vaorra.net/
    <Directory /websites/vaorra.net/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
            Require all granted
    </Directory>

我的服务器是运行,你自己测试一下: http://vaorra.net -> 应该来 "Coming Soon" http://openair-seuzach.ch -> 应该来 "Wartung!"

当您继续 http://alligatorgfx.com/ 时,还会出现 "Wartung!" 但是对于这个域,我希望显示 000-Default VHost 站点,而不是来自 openair-seuzach VHost 的站点。

我的 apache2.conf 文件:

DefaultRuntimeDir ${APACHE_RUN_DIR}

PidFile ${APACHE_PID_FILE}

Timeout 300

KeepAlive On

MaxKeepAliveRequests 100

KeepAliveTimeout 5

User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

HostnameLookups Off

ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel warn

IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

Include ports.conf

AccessFileName .htaccess
<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-                                                Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

IncludeOptional sites-enabled/*.conf

谢谢!

apachectl -S 注释中的输出表明您打算成为非默认虚拟主机的地址规范与您打算成为默认主机的地址规范不同。

换句话说,第一个列出的 <VirtualHost *:80> 只是所有具有 <VirtualHost *:80> 的虚拟主机的默认值。因为你有精确匹配,比如 <VirtualHost 192.168.1.0:80> Apache 甚至不会考虑通配符 *:80 更不用说将它用作 default/catch-all。