8753 sujets

Développement web côté serveur, CMS

Bonjour la liste !

J'ai un petit souci (mais qui grandit vite) avec un site en autohébergement. Le fichier .conf contient ces lignes :
<Directory "/var/www/html/geriadur">
        Options -Indexes +FollowSymLinks
        AllowOverride None      
        Require all granted
    </Directory>
   .....
   ErrorDocument 403 /fazi/403/index.html
   ErrorDocument 404 /fazi/404/index.html
   ErrorDocument 500 /fazi/500/index.html

Chacun des sous-dossiers 403, 404 et 500 contient au minimum un fichier index.html et style.css.
Lorsque je tape une adresse fictive dans la barre d'adresse (ex. : monsite.org/nimportequoi.php) ma jolie page d'erreur 404 personnelle s'affiche bien. Mais si je déclenche une erreur 403, c'est toujours celle par défaut d'Apache qui apparaît...
(Je ne sais pas comment tester une erreur 500).

Pour info, le comportement décrit ci-dessus vaut lorsque je passe par le web. En localhost ce sont toujours les pages par défaut d'Apache. Sans doute une histoire de fichiers qui ne sont pas à la racine mais (/var/www/html/) mais un cran plus bas (/var/www/html/monsite/) mais ça ne me dérange pas, c'est le résultat en ligne qui compte.

Merci de votre aide, et savourez ces jolies pluies d'été...
Modifié par Titen (10 Jul 2024 - 06:54)
Bonjour,

Ca va être difficile de t'aider sans plus d'information. IL faut aller voir les logs.

Sur la page d'erreur d'apache que tu reçois, est-ce que tu n'as pas une phrase supplémentaire du genre "Additionally, an error occurred while trying to use an error document to handle the request" qui pourrait donner un indice sur ce qui se passe ?

La plupart du temps c'est effectivement une erreur de chemin ou de permissions.

Pour tester une erreur 500, tu peux tenter de faire volontairement une erreur PHP ou SQL par exemple. Ou alors volontairement retourner un code HTTP 500 sans contenu.
Bonjour QuentinC,

Effectivement, le message complet est :

Forbidden
You don't have permission to access this resource.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.


De plus je 'avais jamais mis le nez dans les logs (je suis timide...). J'aurais dû ! Voici ce que j'ai pour des essais de ce matin :

[Thu Jul 11 05:39:41.629175 2024] [mpm_prefork:notice] [pid 1167] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Thu Jul 11 05:39:41.629288 2024] [core:notice] [pid 1167] AH00094: Command line: '/usr/sbin/apache2'
[Thu Jul 11 06:49:31.165998 2024] [php:error] [pid 1207] [client 91.92.242.40:53818] script '/var/www/html/geriadur/xmlrpc.php' not found or unable to stat
[Thu Jul 11 07:02:17.393790 2024] [core:error] [pid 1209] [client 8.213.41.202:38350] AH10244: invalid URI path (/cgi-bin/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/bin/sh)
[Thu Jul 11 07:02:17.703203 2024] [core:error] [pid 1206] [client 8.213.41.202:38366] AH10244: invalid URI path (/cgi-bin/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/bin/sh)
[Thu Jul 11 07:02:25.278933 2024] [php:error] [pid 1205] [client 8.213.41.202:58532] script '/var/www/html/index.php' not found or unable to stat
[Thu Jul 11 07:02:25.622541 2024] [php:error] [pid 1205] [client 8.213.41.202:58532] script '/var/www/html/index.php' not found or unable to stat
[Thu Jul 11 07:02:25.804232 2024] [php:error] [pid 1205] [client 8.213.41.202:58532] script '/var/www/html/index.php' not found or unable to stat
[Thu Jul 11 07:20:50.412183 2024] [php:warn] [pid 8144] [client 167.94.146.53:39950] PHP Warning:  Undefined array key "HTTP_USER_AGENT" in /var/www/html/geriadur/index.php on line 3
[Thu Jul 11 07:20:50.412281 2024] [php:warn] [pid 8144] [client 167.94.146.53:39950] PHP Warning:  Undefined array key "HTTP_USER_AGENT" in /var/www/html/geriadur/index.php on line 4
[Thu Jul 11 07:20:50.412292 2024] [php:warn] [pid 8144] [client 167.94.146.53:39950] PHP Warning:  Undefined array key "HTTP_USER_AGENT" in /var/www/html/geriadur/index.php on line 5
[Thu Jul 11 08:39:21.367568 2024] [php:warn] [pid 1208] [client 106.75.11.60:38602] PHP Warning:  Undefined array key "HTTP_USER_AGENT" in /var/www/html/geriadur/index.php on line 3
[Thu Jul 11 08:39:21.367618 2024] [php:warn] [pid 1208] [client 106.75.11.60:38602] PHP Warning:  Undefined array key "HTTP_USER_AGENT" in /var/www/html/geriadur/index.php on line 4
[Thu Jul 11 08:39:21.367626 2024] [php:warn] [pid 1208] [client 106.75.11.60:38602] PHP Warning:  Undefined array key "HTTP_USER_AGENT" in /var/www/html/geriadur/index.php on line 5
[Thu Jul 11 08:40:08.225766 2024] [mpm_prefork:notice] [pid 1167] AH00170: caught SIGWINCH, shutting down gracefully
[Thu Jul 11 08:40:08.439341 2024] [mpm_prefork:notice] [pid 12674] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Thu Jul 11 08:40:08.439420 2024] [core:notice] [pid 12674] AH00094: Command line: '/usr/sbin/apache2'
[Thu Jul 11 08:40:52.762181 2024] [autoindex:error] [pid 12678] [client 192.168.1.254:35748] AH01276: Cannot serve directory /var/www/html/geriadur/notenn/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
[Thu Jul 11 08:40:52.762267 2024] [core:error] [pid 12678] (13)Permission denied: [client 192.168.1.254:35748] AH00035: access to /fazi/403/index.html denied (filesystem path '/var/www/html/geriadur/fazi/403/index.html') because search permissions are missing on a component of the path
[Thu Jul 11 08:46:19.601766 2024] [autoindex:error] [pid 12676] [client 192.168.1.254:47154] AH01276: Cannot serve directory /var/www/html/geriadur/notenn/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
[Thu Jul 11 08:46:19.616350 2024] [core:error] [pid 12676] (13)Permission denied: [client 192.168.1.254:47154] AH00035: access to /fazi/403/index.html denied (filesystem path '/var/www/html/geriadur/fazi/403/index.html') because search permissions are missing on a component of the path
[Thu Jul 11 08:47:01.395333 2024] [autoindex:error] [pid 12675] [client 192.168.1.254:48026] AH01276: Cannot serve directory /var/www/html/geriadur/fonts/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
[Thu Jul 11 08:47:01.395485 2024] [core:error] [pid 12675] (13)Permission denied: [client 192.168.1.254:48026] AH00035: access to /fazi/403/index.html denied (filesystem path '/var/www/html/geriadur/fazi/403/index.html') because search permissions are missing on a component of the path

La ligne trois me laisse perplexe :
 script '/var/www/html/geriadur/xmlrpc.php' not found or unable to stat

je ne vois pas de quoi il est question

les lignes du style :
script '/var/www/html/index.php' not found or unable to stat

s'expliquent par le fait que la racine du site est à /var/www/html/geriadur/index.php. Mais normalement Apache est au courant...

Et les lignes :
Undefined array key "HTTP_USER_AGENT" in /var/www/html/geriadur/index.php on line 3 (4, 5)

font référence à ce code :
<?php
   header( 'content-type: text/html; charset=utf-8' );
   if (stristr($_SERVER['HTTP_USER_AGENT'], "Android")
   || strpos($_SERVER['HTTP_USER_AGENT'], "iPod")
   || strpos($_SERVER['HTTP_USER_AGENT'], "iPhone") )
   {
      header("Location:http://geriaoueg.free.fr/hezoug.php");
   }
   error_reporting(E_ALL);
   ini_set("display_errors", 1);
?>

dont je me sers pour rediriger vers un code destiné aux portables.. Je n'avais pas fais gaffe à ça : ça fait référence à une ancienne version du site hébergée chez Free, je peux changer ça tout de suite.
Ce qui reste étonnant, c'est qu'une page fonctionne (erreur 404) et pas les autres...
Modifié par Titen (11 Jul 2024 - 09:25)
Eurêka ! En relisant jusqu'au bout les logs, j'ai noté les
permissions are missing on a component of the path

Vérification faite, ces deux sous-dossiers (403 et 500) n'vaient pas les droits d'accès nécessaires. Je me demande d'ailleurs comment ça se fait que les trois dossiers, créés en même temps, n'avaient pas les mêmes permissions. Maintenant tout roule !

J'ai au moins appris à consulter les logs, merci Quentin de la leçon !
Longue vie à Alsacrétions !
Modifié par Titen (11 Jul 2024 - 09:27)