Which proxy is it?



It was Apache httpd. I compared the HTML returned with the httpd open source code.

Who is limiting my POST request?

I recently found myself with this response upon making a POST request from one micro service to another:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>413 Request Entity Too Large</title>
</head><body>
<h1>Request Entity Too Large</h1>
The requested resource does not allow request data with POST requests, or the amount of data provided in
the request exceeds the capacity limit.
</body></html>

The POST request was towards a backend service we developed ourselves at the company. This HTML response made no sense though. Our service would not respond with HTML this way.

A reverse proxy part of the infra setup must have been causing the problem. I knew we might have been using both NGINX and Apache reverse proxies at the company. But which one in this case?

Seeking Answers from AI: GPT-4 did not know

In a moment of inspiration I decided to ask GPT-4 if it knew which one:

💡 Question:

Which software capable of acting as a reverse proxy would output this error?

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>413 Request Entity Too Large</title>
</head><body>
<h1>Request Entity Too Large</h1>
The requested resource does not allow request data with POST requests, or the amount of data provided in
the request exceeds the capacity limit.
</body></html>

😢 Answer:

The error message you posted indicates that the server is refusing to process the request
because the request's payload is too large. This is a generic HTTP status code message that
could be from any server or proxy that follows HTTP standards, including reverse proxy software.

So it's saying it can be from any server or proxy. Not very helpful.

Checking out the source

Luckily both Apache httpd and NGINX are open source.

👀 Let's just check them out and take a look:

$ git clone git@github.com:apache/httpd.git
$ git clone git@github.com:nginx/nginx.git

Simple text search can be a powerful tool in large code bases. I mostly use IntelliJ when coding Java, but VSCode works great for text search:

Screenshot of text search in VSCode

Searching for the part or the amount of data provided yielded no hits in NGINX, but a single exact match in the httpd code base:

case HTTP_REQUEST_ENTITY_TOO_LARGE:
    return(apr_pstrcat(p,
                        "The requested resource does not allow request data with ",
                        ap_escape_html(r->pool, r->method),
                        " requests, or the amount of data provided in\n"
                        "the request exceeds the capacity limit.\n",
                        NULL));

☝️ Finding that code was super useful in communication with the infra team as well. I basically said:

We can be certain it's Apache httpd. Here's the corresponding code on GitHub: https://github.com/apache/httpd/blob/3da54a7f168484eb2e9c681f9ca59f9076cbb002/modules/http/http_protocol.c#L1056

This made the situation clear enough. The infra team could proceed. They changed some Apache httpd config and the issue was resolved ✨.