【问题标题】:Apache2 000-Default VHost won't be choosen by a RequestApache2 000-Default VHost 不会被请求选择
【发布时间】:2019-04-27 06:32:36
【问题描述】:

我有一个安装了 Debian GNU/Linux 9 (stretch) 和 Apache/2.4.25 (Debian) 的 Linux 服务器。我想在我的服务器上托管多个网站。例如一个主要网站和 2-3 个较小的朋友网站。我还希望在请求到达未在 VHosts 中配置的 Web 服务器时显示默认页面(例如 de IP-Address)。例如 Welcome on 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>

openair-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 -> 应该是“即将推出” 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

谢谢!

【问题讨论】:

标签: linux debian apache2 apache2.4 debian-stretch


【解决方案1】:

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

换句话说,第一个列出的 &lt;VirtualHost *:80&gt; 只是所有具有确切 &lt;VirtualHost *:80&gt; 的虚拟主机的默认值。由于您有完全匹配,例如&lt;VirtualHost 192.168.1.0:80&gt; Apache 甚至不会考虑通配符 *:80 更不用说将其用作默认值/catch-all。

【讨论】:

  • 所以我必须到处使用&lt;VirtualHost *:80&gt;?
猜你喜欢
  • 1970-01-01
  • 2016-05-27
  • 2014-12-19
  • 2018-04-29
  • 2023-03-12
  • 2016-04-23
  • 1970-01-01
  • 2013-08-24
  • 1970-01-01
相关资源
最近更新 更多