Skip to content
Advertisement

Often getting empty $_POST data and proxy_fcgi error / Apache2 / PHP-FPM

I have an Apache2 server with PHP-FPM (working on Ubuntu 20) and often I getting empty $_POST data from the clients, but Content-Length in header is > 0. I have not a small traffic (~20 req/sec (max) on PHP-FPM) and from some clients I receive an empty POST request (it can be 1 in hour or sometimes > 10). Here is the example header that I receiving:

JavaScript

And some info from $_SERVER:

JavaScript

As you can see Content-Length is > 0, but $_POST data array is empty. At the same time, this empty POST request often following with proxy_fcgi error:

JavaScript

Also when this error occurs, in the access.log I see 408 code. And I don’t know the problem is the Apache configuration or PHP-FPM, because POST data that I sending from clients is small and it’s only text data. Strange that on the previous server (cloudways) I didn’t have those problems. But now when I did my own server, this magic error happens. Maybe they just ignore these types of errors or the timeout value was to big. My scripts execute time is < 0.1 seconds and I don’t need big timeout values (I guess).

Here is some important settings in my configurations:

apache2.conf

JavaScript

/apache2/sites-available/example.com.conf

JavaScript

/php/7.4/fpm/pool.d/example.com.conf

JavaScript

Advertisement

Answer

Fixed the appearance of timeout errors by switching from HTTP/1.1 protocol to HTTP/2. Empty POST requests now come rarely, but they do.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement