gpt4 book ai didi

linux - Apache2 000-请求不会选择默认 VHost

转载 作者:太空宇宙 更新时间:2023-11-04 05:12:36 25 4
gpt4 key购买 nike

我有一台安装了 Debian GNU/Linux 9 (stretch) 和 Apache/2.4.25 (Debian) 的 Linux 服务器。我想在我的服务器上托管多个网站。例如,一个主要网站和 2-3 个供 friend 使用的较小网站。我还希望当请求到达未在 VHost 中配置的 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>

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

谢谢!

最佳答案

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

换句话说,第一个列出的<VirtualHost *:80>仅是所有具有 <VirtualHost *:80> 的虚拟主机的默认值。由于您有精确匹配,例如 <VirtualHost 192.168.1.0:80> Apache 甚至不会考虑通配符 *:80 更不用说将其用作默认/包罗万象了。

关于linux - Apache2 000-请求不会选择默认 VHost,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53467127/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com