https://bz.apache.org/bugzilla/show_bug.cgi?id=69101
Bug ID: 69101
Summary: Redirect 200 returns a 404 error to the client but
logs 200 OK in access log
Product: Apache httpd-2
Version: 2.4.59
Hardware: PC
OS: Linux
Status: NEW
Severity: major
Priority: P2
Component: All
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
Good morning,
I have a freshly installed Debian 11, Apache/2.4.59 installed from the official
apt repository, with just the default modules + mod_ssl loaded, and the
default-ssl.conf site enabled.
No other changes whatsoever. No proxies, no load balancers, firewalls, client
and server sitting in the same internal subnet.
I need to serve a custom error page for 404 errors, but I want to serve it with
a 200 OK status code for monitoring and SLA/SLO reasons.
I have created the following files in the DocumentRoot:
/var/www/html/index.html: contains the text "This is the index"
/var/www/html/static/custom404.html: contains the text "This is an error!"
They're both reachable and return 200 when requested on
https://example.com/index.html and https://example.com/static/custom404.html
Then I added the directive
ErrorDocument 404 /static/custom404.html
to default-ssl.conf, and this works: whenever I request a document that does
not exist, Apache will serve the custom page saying "This is an error!"
Also, the access log will read something like:
"GET /doesnotexist.html HTTP/1.1" 404 2216 "-" "curl/7.74.0"
Which is expected.
Unfortunately, as soon as I add the following directive:
Redirect 200 /static/custom404.html
Apache serves an inconsistent response: the client will get an error page
#########################
> GET /doesnotexist.html HTTP/1.1
[...]
< HTTP/1.1 404 Not Found
[...]
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the
request.</p>
<hr>
#########################
But at the same time the logs will read something like
==> /var/log/apache2/error.log <==
Request received from client: GET /doesnotexist.html HTTP/1.1
File does not exist: /var/www/html/doesnotexist.html
==> /var/log/apache2/access.log <==
"GET /doesnotexist.html HTTP/1.1" 200 2476 "-" "curl/7.74.0"
No other errors are logged, even with LogLevel trace6, so it's impossible to
understand what's the root cause of the error page returned to the client.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]