skip to Main Content

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

  1. If LimitRequestFieldSize <16k (e.g. 12k) and cookie_size <12k (e.g. 8k) => 200 status.
  2. If LimitRequestFieldSize <16k (e.g. 12k) and cookie_size 13k => 400 status.
  3. If LimitRequestFieldSize >16k (e.g. 20k) and cookie_size 13k => 200 status.
  4. If LimitRequestFieldSize >16k (e.g. 20k) and cookie_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


  1. 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:

    There are a handful of potential reasons behind the HTTP 408 request
    timeout error. These causes include:

    Network latency Clients timing out Servers being too busy to handle
    the request The 408 Request Timeout error means the request you sent
    to the website server took longer than the server was prepared to
    wait.
    It can happen due to heavy traffic on the internet or a slow
    connection on your side.

    The problem with this status code is that it can occur for both
    client-side and server-side-related reasons. In other words, although
    the 408 error is categorized as a client error, this doesn’t
    necessarily mean the issue stems from the browser or device. It’s
    possible that the server is misconfigured or isn’t handling requests
    correctly.

    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.

    TimeOut 600
    ProxyTimeout 600
    

    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.

    LimitRequestLine 32768
    LimitRequestBody 32768
    

    Check your PHP Configuration:

    Check php.ini settings for limits related to input processing:

    max_input_time = 600
    request_terminate_timeout = 600
    

    Add debugging params / enable debugging

    Enable detailed logging in your Apache to get more insights into why the 408 status is being triggered.
    apache

    LogLevel debug
    

    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.

    Login or Signup to reply.
  2. 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

    sudo nano /opt/bitnami/apache2/conf/httpd.conf
    

    Add the required directives under the appropriate section. You might want to add them near the top of the file or under the section.

    LimitRequestLine 8190
    LimitRequestFields 100
    LimitRequestFieldSize 32768
    LimitRequestBody 0
    

    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.

    post_max_size = 32M
    upload_max_filesize = 32M
    max_input_vars = 3000
    

    Enable Error Logging in PHP:

    error_reporting = E_ALL
    display_errors = On
    log_errors = On
    error_log = /path/to/php_error_log
    

    Enable Error Logging in httpd.conf:

    LogLevel debug
    ErrorLog /path/to/error_log
    

    Timeout Configuration:

    Apache (/opt/bitnami/apache2/conf/httpd.conf):

    Timeout 600
    ProxyTimeout 600
    

    PHP (in PHP.ini)

    max_execution_time = 600
    max_input_time = 600
    
    

    Restart the Apache Server to apply the changes:

    sudo /opt/bitnami/ctlscript.sh restart apache
    

    Verify the Changes

    apachectl -M
    apachectl -S
    
    

    Use CURL for Testing

    curl -vk -H "X-Header: $(cat file20k)" https://url-to-my-wordpress:8443/wp-login.php
    

    In case of problem, review the logs

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search