I have [bitnami/wordpress] deployed on my Kubernetes cluster with default Apache configuration. My browser sends large cookies in the header to the WP website because the domain is co-located with a cookie domain containing a set size of 20kb.
If I add the line LimitRequestFieldSize 32768
to the Apache configuration, I can theoretically send 32kb of header data.
For smaller header sizes, LimitRequestFieldSize 16k
, the Apache server responded with 200 if the header was under the limit and 400 if it was over the limit. However, for LimitRequestFieldSize > 16k
and above, I only got 408 HTTP status codes back, with no error logs showing why.
I assume that there are some php
or WordPress limitations that could be in play.
My header is at least 20k, and I can’t make it smaller. No external proxy limitations are in effect.
The command I used is:
curl -vk -H "X-Header: $(cat file16k)" https://url-to-my-wordpress:8443/wp-login.php
and I expected: 200
, but I got 408
.
TL;DR
- If
LimitRequestFieldSize <16k
(e.g. 12k) andcookie_size <12k
(e.g. 8k) => 200 status. - If
LimitRequestFieldSize <16k
(e.g. 12k) andcookie_size 13k
=> 400 status. - If
LimitRequestFieldSize >16k
(e.g. 20k) andcookie_size 13k
=> 200 status. - If
LimitRequestFieldSize >16k
(e.g. 20k) andcookie_size 18k
=> 408 status (immediately returned).
(408 status (immediately returned) if cookie_size >16k
and LimitRequestFieldSize >16k
, therefore, setting LimitRequestFieldSize
above 16k does not help. The change in the response code may indicate that a downstream consumer of the request rejects handling it.)
2
Answers
First off, 408 error is actually a request timeout.
E.g. copying text directly from the website https://kinsta.com/knowledgebase/http-408/, we see the
following:
I additionally hope, that this error is potentially not being caused by some reverse-proxy in the middle – but let’s assume and debug that it’s the apache server.
Steps to fix/debug
Try the following:
Increase the Apache Timeout
Increase the Timeout and ProxyTimeout settings in the Apache configuration.
See: https://httpd.apache.org/docs/2.4/mod/core.html
Adjust the buffer Sizes:
Increase the buffer sizes for request headers and bodies to handle large headers more efficiently.
Check your PHP Configuration:
Check php.ini settings for limits related to input processing:
Add debugging params / enable debugging
Enable detailed logging in your Apache to get more insights into why the 408 status is being triggered.
apache
If all the above fail, do look into your reverse proxies and downstream services.
Check their configurations, and specifically to see if they can handle large headers and have appropriate timeout settings.
I suggest you to work on Apache Configuration, PHP Configuration and WordPress Configuration to handle the large headers beyond a certain size.
As you are on [bitnami/wordpress], so Apache configuration file might be in this path:
Apache Configuration
Add the required directives under the appropriate section. You might want to add them near the top of the file or under the section.
This will list the loaded configuration and current modules. Make sure there are no errors or warnings.
PHP Configuration:
You need to apply the following changes in the PHP.ini to handle the limitations on the size of the request header.
Enable Error Logging in PHP:
Enable Error Logging in httpd.conf:
Timeout Configuration:
Apache (/opt/bitnami/apache2/conf/httpd.conf):
PHP (in PHP.ini)
Restart the Apache Server to apply the changes:
Verify the Changes
Use CURL for Testing
In case of problem, review the logs