eigentlich sollte das kein großes Ding sein, dachte ich ... ich möchte unter Debian 11 und Apache2 eigene Fehlerseiten hinzufügen in der Hoffnung, dass diese Seiten dann in jedem Browser ordentlich und identisch aussehen. Zum Test habe ich erstmal in die sites-available/000-default.conf folgendes (ErrorDocument) hinzugefügt:
Code: Alles auswählen
root@example:/etc/apache2$ cat sites-available/000-default.conf|grep -v '#'
<VirtualHost *:80>
ServerName example.org
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html>
Options All
AllowOverride All
Require all granted
ErrorDocument 500 "Das Formular wurde entfernt."
ErrorDocument 404 "Das Formular wurde entfernt."
ErrorDocument 502 "Das Formular wurde entfernt."
ErrorDocument 400 "Das Formular wurde entfernt."
ErrorDocument 504 "Das Formular wurde entfernt."
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.org
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
root@example:/etc/apache2$
kann man es testen, da kommt:echo -en "GET /foo HTTP/1.0\n\n" | nc 127.0.0.1 80
Code: Alles auswählen
root@example:/etc/apache2$ echo -en "GET /foo HTTP/1.0\n\n" | nc 127.0.0.1 80
HTTP/1.1 400 Bad Request
Date: Thu, 24 Feb 2022 11:32:45 GMT
Server: Apache/2.4.52 (Debian)
Content-Length: 306
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.4.52 (Debian) Server at example.org Port 80</address>
</body></html>
root@example:/etc/apache2$
Code: Alles auswählen
127.0.0.1 - - [24/Feb/2022:12:46:39 +0100] "GET /foo HTTP/1.0\n" 400 488 "-" "-"
Code: Alles auswählen
80.xxx.xxx.xxx - - [24/Feb/2022:12:52:00 +0100] "GET /gibtsicht HTTP/1.1" 500 770 "-" "Mozilla/5. ....
Auch in die SSL-Config habe ich es eingetragen:
Code: Alles auswählen
root@example:/etc/apache2$ cat sites-enabled/000-default-le-ssl.conf|grep -v '#'
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName example.org
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html>
Options All
AllowOverride All
Require all granted
ErrorDocument 500 "Das Formular wurde entfernt."
ErrorDocument 404 "Das Formular wurde entfernt."
ErrorDocument 502 "Das Formular wurde entfernt."
ErrorDocument 503 "Das Formular wurde entfernt."
ErrorDocument 504 "Das Formular wurde entfernt."
</Directory>
SSLCertificateFile /etc/letsencrypt/live/example.org/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.org/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
root@example:/etc/apache2$
Vielleicht noch wichtig, das ist eine VM auf der nur eine einzige Seite läuft direkt im DocumentRoot. Die Konfiguration ist bis auf obige Dateien noch ziemlich Standard.