我设置了基于名称的虚拟主机,其中托管了 03 个域,我的问题是当我从任何域请求任何页面时,它会尝试从主主机 ip(15.xxx)为其提供服务。
|- 15.x.x.x /var/www/html/public_html
|- domain01.com /var/www/html/apple.highschoolhelper.org/public_html
|- domain02.com /var/www/html/orange.highschoolhelper.org/public_html
|- domain03.com /var/www/html/avocado.highschoolhelper.org/public_html
我的httpd.conf:
ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin root@localhost
ServerName 15.0.0.0:80
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/var/www/html"
<Directory "/var/www">
AllowOverride None
Require all granted
</Directory>
<Directory "/var/www/html/public_html">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "logs/access_log" combined
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule mime_module>
TypesConfig /etc/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>
AddDefaultCharset UTF-8
<IfModule mime_magic_module>
MIMEMagicFile conf/magic
</IfModule>
EnableSendfile on
IncludeOptional conf.d/*.conf
IncludeOptional conf.d/domains/*.conf
其他域配置:
<VirtualHost 15.0.0.0:80>
ServerName apple.highschoolhelper.org
ServerAlias apple.highschoolhelper.org
DocumentRoot /var/www/html/apple.highschoolhelper.org/public_html
ServerAdmin [email protected]
DirectoryIndex index.html index.php
LogLevel warn
<Directory /var/www/html/apple.highschoolhelper.org/public_html>
IndexIgnoreReset ON
IndexIgnore .well-known
Options -Indexes +FollowSymLinks
AllowOverride All
</Directory>
ErrorLog /var/log/httpd/apple.highschoolhelper.org-error.log
CustomLog /var/log/httpd/apple.highschoolhelper.org-access.log combined
</VirtualHost>
更新:我在 access_log 中看到以下几行,似乎apple
域名已被请求:
41.x.x.x 15.x.x.x - - [11/May/2020:04:54:00 +0000] "GET / HTTP/1.1" 403 3630 "-" "Mozilla/5.0"
41.x.x.x apple.highschoolhelper.org - - [11/May/2020:04:54:06 +0000] "GET / HTTP/1.1" 403 3630 "-" "Mozilla/5.0"
41.x.x.x apple.highschoolhelper.org - - [11/May/2020:04:54:06 +0000] "GET /favicon.ico HTTP/1.1" 404 196 "-" "Mozilla/5.0"