1 votes

Apache2 - si la page n'est pas trouvée, elle est servie par un autre domaine.

Je suis confronté à un comportement étrange avec l'IP de mon hôte principal et les hôtes virtuels servis, en gros, j'ai ce qui suit :

|- 148.x.x.x            /var/www/html/public_html
|- domain01.com         /var/www/html/domain01.com/public_html
|- domain02.com         /var/www/html/domain02.com/public_html
|- domain03.com         /var/www/html/domain03.com/public_html

Numéro 01 : Maintenant, si j'accède à n'importe quelle page sur 148.x.x.x, Je reçois 404 code http et si le même nom de page est hébergé dans domain01.com puis le contenu de celui-ci s'affiche.

Numéro 02 : Si une page n'est pas trouvée dans d'autres domaines et qu'il s'est passé le même nom de page hébergé dans domain01 puis il sera servi. Mon httpd.conf :

ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin root@localhost
ServerName 148.x.x.x:80

<Directory />
    AllowOverride none
    Require all denied
</Directory>

DocumentRoot "/var/www/html/public_html"

<Directory "/var/www">
    AllowOverride None
    Require all granted
</Directory>

<Directory "/var/www/html/public_html">
    Options All Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</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 application/x-httpd-php .php
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>

EnableSendfile on

<IfModule mod_http2.c>
    Protocols h2 h2c http/1.1
</IfModule>

NameVirtualHost *
IncludeOptional conf.d/*.conf
IncludeOptional conf.d/domains/*.conf

Configuration de l'hôte virtuel :

<VirtualHost *:80>
    ServerName domain01.com
    ServerAlias www.domain01.com
    ServerAdmin webmaster@domain01
    DocumentRoot /var/www/html/domain01/public_html

    <Directory /var/www/html/domain01/public_html>
        Options -Indexes +FollowSymLinks
        AllowOverride All
    </Directory>

    ErrorLog /var/log/httpd/domain01-error.log
    CustomLog /var/log/httpd/domain01-access.log combined
</VirtualHost>

Les autres domaines partagent la même configuration.

Journal des erreurs :

[Sun May 10 04:35:40.554754 2020] [suexec:notice] [pid 20023] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Sun May 10 04:35:40.579226 2020] [lbmethod_heartbeat:notice] [pid 20023] AH02282: No slotmem from mod_heartmonitor
[Sun May 10 04:35:40.579272 2020] [http2:warn] [pid 20023] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
[Sun May 10 04:35:40.579277 2020] [http2:warn] [pid 20023] AH02951: mod_ssl does not seem to be enabled
[Sun May 10 04:35:40.608931 2020] [mpm_prefork:notice] [pid 20023] AH00163: Apache/2.4.41 () PHP/7.3.16 configured -- resuming normal operations
[Sun May 10 04:35:40.608967 2020] [core:notice] [pid 20023] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sun May 10 04:54:07.699619 2020] [mpm_prefork:notice] [pid 20023] AH00170: caught SIGWINCH, shutting down gracefully
[Sun May 10 04:54:08.784661 2020] [suexec:notice] [pid 20172] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Sun May 10 04:54:08.815681 2020] [lbmethod_heartbeat:notice] [pid 20172] AH02282: No slotmem from mod_heartmonitor
[Sun May 10 04:54:08.815727 2020] [http2:warn] [pid 20172] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
[Sun May 10 04:54:08.815732 2020] [http2:warn] [pid 20172] AH02951: mod_ssl does not seem to be enabled
[Sun May 10 04:54:08.845184 2020] [mpm_prefork:notice] [pid 20172] AH00163: Apache/2.4.41 () PHP/7.3.16 configured -- resuming normal operations
[Sun May 10 04:54:08.845215 2020] [core:notice] [pid 20172] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sun May 10 04:55:20.189266 2020] [mpm_prefork:notice] [pid 20172] AH00170: caught SIGWINCH, shutting down gracefully
[Sun May 10 04:55:21.262210 2020] [suexec:notice] [pid 20236] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Sun May 10 04:55:21.289998 2020] [lbmethod_heartbeat:notice] [pid 20236] AH02282: No slotmem from mod_heartmonitor
[Sun May 10 04:55:21.290044 2020] [http2:warn] [pid 20236] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
[Sun May 10 04:55:21.290048 2020] [http2:warn] [pid 20236] AH02951: mod_ssl does not seem to be enabled
[Sun May 10 04:55:21.314344 2020] [mpm_prefork:notice] [pid 20236] AH00163: Apache/2.4.41 () PHP/7.3.16 configured -- resuming normal operations
[Sun May 10 04:55:21.314377 2020] [core:notice] [pid 20236] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sun May 10 04:56:16.858055 2020] [mpm_prefork:notice] [pid 20236] AH00170: caught SIGWINCH, shutting down gracefully
[Sun May 10 04:56:17.942478 2020] [suexec:notice] [pid 20300] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Sun May 10 04:56:17.967937 2020] [lbmethod_heartbeat:notice] [pid 20300] AH02282: No slotmem from mod_heartmonitor
[Sun May 10 04:56:17.967989 2020] [http2:warn] [pid 20300] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
[Sun May 10 04:56:17.967994 2020] [http2:warn] [pid 20300] AH02951: mod_ssl does not seem to be enabled
[Sun May 10 04:56:17.995419 2020] [mpm_prefork:notice] [pid 20300] AH00163: Apache/2.4.41 () PHP/7.3.16 configured -- resuming normal operations
[Sun May 10 04:56:17.995465 2020] [core:notice] [pid 20300] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sun May 10 09:52:00.857620 2020] [mpm_prefork:notice] [pid 20300] AH00170: caught SIGWINCH, shutting down gracefully
[Sun May 10 09:52:18.179419 2020] [suexec:notice] [pid 21600] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Sun May 10 09:52:18.208499 2020] [lbmethod_heartbeat:notice] [pid 21600] AH02282: No slotmem from mod_heartmonitor
[Sun May 10 09:52:18.208546 2020] [http2:warn] [pid 21600] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
[Sun May 10 09:52:18.208550 2020] [http2:warn] [pid 21600] AH02951: mod_ssl does not seem to be enabled
[Sun May 10 09:52:18.240064 2020] [mpm_prefork:notice] [pid 21600] AH00163: Apache/2.4.41 () PHP/7.3.16 configured -- resuming normal operations
[Sun May 10 09:52:18.240096 2020] [core:notice] [pid 21600] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

2voto

Batman Points 36

Sans connaître le nom d'hôte spécifique, il est difficile de déterminer s'il s'agit d'un problème de registre DNS ou d'un problème de configuration du serveur, mais il y a quelques éléments que vous pouvez mettre à jour dans votre configuration et qui peuvent aider à résoudre le problème, ou du moins, à prévenir les problèmes futurs s'ils sont liés au DNS.

Sur le fichier d'hôte virtuel, vous devez vous assurer que vous avez :

<VirtualHost *:80>
    ServerName domain01.com
    ServerAlias www.domain01.com
    ServerAdmin webmaster@domain01.com
    DirectoryIndex index.html
    DocumentRoot /var/www/html/domain01/public_html
    LogLevel warn
    ErrorLog /var/log/httpd/domain01-error.log
    CustomLog /var/log/httpd/domain01-access.log combined

    <Directory "/var/www/html/domain01/public_html">
        Options -Indexes +FollowSymLinks
        AllowOverride All
    </Directory>
</VirtualHost>

Si le répertoire n'est pas correctement encadré par des guillemets dans une chaîne de caractères, il vous manque l'option domain01 TLD, et vous servez le ServerName y ServerAlias comme les mêmes objets, sans TLD.

J'ai oublié de mentionner : Les hôtes virtuels avec IP sont typiquement servis de cette manière :

<VirtualHost 148.X.X.X>
  DocumentRoot /wwwdomain01
  ServerName www.domain01.com
</VirtualHost>

<VirtualHost 148.X.X.X>
  DocumentRoot /wwwdomain02
  ServerName www.domain02.com
</VirtualHost>

C'est une excellente ressource

Si vous ne voulez pas utiliser l'IP explicite, alors vous pouvez toujours utiliser listen comme expliqué via le docs apache ici : écouter et ici : serveur virtuel

1voto

DubStep Points 264

C'est parce que les hôtes virtuels écoutent à *. Cela signifie donc que toute adresse IP configurée pour le serveur (la première configurée sera généralement celle qui répondra essentiellement) peut répondre à la requête. Vous devez utiliser l'adresse IP spécifiquement pour cet hôte virtuel.

SistemesEz.com

SystemesEZ est une communauté de sysadmins où vous pouvez résoudre vos problèmes et vos doutes. Vous pouvez consulter les questions des autres sysadmins, poser vos propres questions ou résoudre celles des autres.

Powered by:

X