Weird problem with Apache and php

429 views
Skip to first unread message

Niels Kobschätzki

unread,
Jun 9, 2021, 3:48:24 PM6/9/21
to freebsd-...@freebsd.org
Hi,

I have a weird problem on an old machine (FBSD 11.2, Apache 2.4, php 7.1 - please don’t ask): I am trying to upload files via a simple php-script. I am using mod_proxy_fcgi for connecting Apache to php-fpm. When I try to upload a file of a size between 63 and 64 KByte it works fine. As soon as the file is 1 Byte bigger the following happens:
The upload starts and I see the temporary file popping up in /tmp and it is at max ca 40KByte in size. Interestingly it was today a different size in Bytes then with my tests yesterday but it is over the day always the exact same size. Then php hangs and suddenly php-fpm disconnects and errors out and the browser shows that something went wrong - maybe the server is busy, but no error code. That suddenly is always around 18 seconds and it is also always the same time.

I attached truss to the php-fpm-process that handles the upload and you see it start, then nothing happens and php-fpm releases the connection. I did a tcpdump on the loopback-interface on port 9000 and you see that the upload starts and suddenly there is an error uploading the file-message in the dump.

I checked the post_max_size and the upload_max_size, they are at over 100MB. My request timeout is at 60 seconds. I tried a higher timeout for the proxy from mod_proxy and it didn’t help. The login-class looks good. In /tmp are files bigger than that size and there is no quota. I tried to play around with mod_reqtimeout and it didn’t help. I found something that this might happen when Apache is compiled with AP2FILTER and it isn’t. I checked the involved .htaccess and there are php value-directives.

The crazy thing is: I have an Ubuntu 18.04 with pho 7.1, the same php-settings and Apache-configuration (or as close as I could get them) and there it works perfectly fine.

Does anybody have any idea what could be the problem or another idea where I could look? I checked now everything I could imagine and I just can’t explain why the php suddenly hangs, then dies and unlinks the temporary file. There are no errors in the php_error.log. There is nothing in the php-fpm.log.
I see only this in the Apache-log:

[Tue Jun 08 14:23:56.744245 2021] [proxy_fcgi:error] [pid 2700:tid 34504518400] (70007)The timeout specified has expired: [client XXX.XXX.XXX.XXX:51340] AH01075: Error dispatching request to : (reading input brigade), referer: https://website.TLD/path/to/script.php

Any idea would be helpful. Maybe a sysctl that could matter? Some config in /etc I am overlooking? I just can’t explain it.

Desperate greetings,

Niels

Valeri Galtsev

unread,
Jun 9, 2021, 4:35:28 PM6/9/21
to freebsd-...@freebsd.org

On 6/9/21 2:48 PM, Niels Kobschätzki wrote:
> Hi,
>
> I have a weird problem on an old machine (FBSD 11.2, Apache 2.4, php 7.1 - please don’t ask): I am trying to upload files via a simple php-script. I am using mod_proxy_fcgi for connecting Apache to php-fpm. When I try to upload a file of a size between 63 and 64 KByte it works fine. As soon as the file is 1 Byte bigger the following happens:
> The upload starts and I see the temporary file popping up in /tmp and it is at max ca 40KByte in size. Interestingly it was today a different size in Bytes then with my tests yesterday but it is over the day always the exact same size. Then php hangs and suddenly php-fpm disconnects and errors out and the browser shows that something went wrong - maybe the server is busy, but no error code. That suddenly is always around 18 seconds and it is also always the same time.
>
> I attached truss to the php-fpm-process that handles the upload and you see it start, then nothing happens and php-fpm releases the connection. I did a tcpdump on the loopback-interface on port 9000 and you see that the upload starts and suddenly there is an error uploading the file-message in the dump.
>
> I checked the post_max_size and the upload_max_size, they are at over 100MB.

I would also check memory_limit and make it larger than the above.

Just a shot in the dark.

Valeri

> My request timeout is at 60 seconds. I tried a higher timeout for the proxy from mod_proxy and it didn’t help. The login-class looks good. In /tmp are files bigger than that size and there is no quota. I tried to play around with mod_reqtimeout and it didn’t help. I found something that this might happen when Apache is compiled with AP2FILTER and it isn’t. I checked the involved .htaccess and there are php value-directives.
>
> The crazy thing is: I have an Ubuntu 18.04 with pho 7.1, the same php-settings and Apache-configuration (or as close as I could get them) and there it works perfectly fine.
>
> Does anybody have any idea what could be the problem or another idea where I could look? I checked now everything I could imagine and I just can’t explain why the php suddenly hangs, then dies and unlinks the temporary file. There are no errors in the php_error.log. There is nothing in the php-fpm.log.
> I see only this in the Apache-log:
>
> [Tue Jun 08 14:23:56.744245 2021] [proxy_fcgi:error] [pid 2700:tid 34504518400] (70007)The timeout specified has expired: [client XXX.XXX.XXX.XXX:51340] AH01075: Error dispatching request to : (reading input brigade), referer: https://website.TLD/path/to/script.php
>
> Any idea would be helpful. Maybe a sysctl that could matter? Some config in /etc I am overlooking? I just can’t explain it.
>
> Desperate greetings,
>
> Niels
>

--
++++++++++++++++++++++++++++++++++++++++
Valeri Galtsev
Sr System Administrator
Department of Astronomy and Astrophysics
Kavli Institute for Cosmological Physics
University of Chicago
Phone: 773-702-4247
++++++++++++++++++++++++++++++++++++++++
_______________________________________________
freebsd-...@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questi...@freebsd.org"

Daniel Dowse

unread,
Jun 9, 2021, 7:51:28 PM6/9/21
to freebsd-...@freebsd.org
On Wed, 9 Jun 2021 21:48:04 +0200
Niels Kobschätzki <ni...@kobschaetzki.net> wrote:

> Hi,
>
> I have a weird problem on an old machine (FBSD 11.2, Apache 2.4, php 7.1 -
> please don’t ask): I am trying to upload files via a simple php-script. I am
> using mod_proxy_fcgi for connecting Apache to php-fpm. When I try to upload a
> file of a size between 63 and 64 KByte it works fine. As soon as the file is

> 1 Byte bigger the following happens: [snip]

Hi niels,

i would suggest to look at mod_reqtimeout and continue with loglevel
debug/trace.

best regards.

--
Daniel Dowse <freeb...@daemonbytes.net>

Niels Kobschätzki

unread,
Jun 9, 2021, 10:15:06 PM6/9/21
to Valeri Galtsev, freebsd-...@freebsd.org


Schöne Grüße

Niels

> On 9. Jun 2021, at 22:35, Valeri Galtsev <gal...@kicp.uchicago.edu> wrote:
>
> 
>
>> On 6/9/21 2:48 PM, Niels Kobschätzki wrote:
>> Hi,
>> I have a weird problem on an old machine (FBSD 11.2, Apache 2.4, php 7.1 - please don’t ask): I am trying to upload files via a simple php-script. I am using mod_proxy_fcgi for connecting Apache to php-fpm. When I try to upload a file of a size between 63 and 64 KByte it works fine. As soon as the file is 1 Byte bigger the following happens:
>> The upload starts and I see the temporary file popping up in /tmp and it is at max ca 40KByte in size. Interestingly it was today a different size in Bytes then with my tests yesterday but it is over the day always the exact same size. Then php hangs and suddenly php-fpm disconnects and errors out and the browser shows that something went wrong - maybe the server is busy, but no error code. That suddenly is always around 18 seconds and it is also always the same time.
>> I attached truss to the php-fpm-process that handles the upload and you see it start, then nothing happens and php-fpm releases the connection. I did a tcpdump on the loopback-interface on port 9000 and you see that the upload starts and suddenly there is an error uploading the file-message in the dump.
>> I checked the post_max_size and the upload_max_size, they are at over 100MB.
>
> I would also check memory_limit and make it larger than the above.

That’s already the the case.

Niels

Niels Kobschätzki

unread,
Jun 10, 2021, 3:21:10 AM6/10/21
to freebsd-...@freebsd.org
On 10 Jun 2021, at 1:50, Daniel Dowse wrote:

> On Wed, 9 Jun 2021 21:48:04 +0200
> Niels Kobschätzki <ni...@kobschaetzki.net> wrote:
>
>> Hi,
>>
>> I have a weird problem on an old machine (FBSD 11.2, Apache 2.4, php 7.1 -
>> please don’t ask): I am trying to upload files via a simple php-script. I am
>> using mod_proxy_fcgi for connecting Apache to php-fpm. When I try to upload a
>> file of a size between 63 and 64 KByte it works fine. As soon as the file is
>> 1 Byte bigger the following happens: [snip]
>
> Hi niels,
>
> i would suggest to look at mod_reqtimeout and continue with loglevel
> debug/trace.

I tried it and didn’t get any new information out of that:

[Thu Jun 10 09:14:58.652992 2021] [proxy:trace2] [pid 4186:tid 34504614656] proxy_util.c(2155): [client this.is.my.ip:62429] *: using default reverse proxy worker for fcgi://127.0.0.1:9000/usr/local/www/apache22/data/www.somedomain.de/path/general.php (no keepalive), referer: https://subw.somedomain.de/path/general.html
[Thu Jun 10 09:14:58.653035 2021] [proxy:debug] [pid 4186:tid 34504614656] mod_proxy.c(1247): [client this.is.my.ip:62429] AH01143: Running scheme fcgi handler (attempt 0), referer: https://subw.somedomain.de/path/general.html
[Thu Jun 10 09:14:58.653070 2021] [proxy_fcgi:debug] [pid 4186:tid 34504614656] mod_proxy_fcgi.c(1019): [client this.is.my.ip:62429] AH01076: url: fcgi://127.0.0.1:9000/usr/local/www/apache22/data/www.somedomain.de/path/general.php proxyname: (null) proxyport: 0, referer: https://subw.somedomain.de/path/general.html
[Thu Jun 10 09:14:58.653109 2021] [proxy_fcgi:debug] [pid 4186:tid 34504614656] mod_proxy_fcgi.c(1028): [client this.is.my.ip:62429] AH01078: serving URL fcgi://127.0.0.1:9000/usr/local/www/apache22/data/www.somedomain.de/path/general.php, referer: https://subw.somedomain.de/path/general.html
[Thu Jun 10 09:14:58.653160 2021] [proxy:debug] [pid 4186:tid 34504614656] proxy_util.c(2325): AH00942: FCGI: has acquired connection for (*)
[Thu Jun 10 09:14:58.653204 2021] [proxy:debug] [pid 4186:tid 34504614656] proxy_util.c(2379): [client this.is.my.ip:62429] AH00944: connecting fcgi://127.0.0.1:9000/usr/local/www/apache22/data/www.somedomain.de/path/general.php to 127.0.0.1:9000, referer: https://subw.somedomain.de/path/general.html
[Thu Jun 10 09:14:58.653249 2021] [proxy:debug] [pid 4186:tid 34504614656] proxy_util.c(2588): [client this.is.my.ip:62429] AH00947: connected /usr/local/www/apache22/data/www.somedomain.de/path/general.php to 127.0.0.1:9000, referer: https://subw.somedomain.de/path/general.html
[Thu Jun 10 09:14:58.653306 2021] [proxy:trace2] [pid 4186:tid 34504614656] proxy_util.c(3022): FCGI: fam 2 socket created to connect to *
[Thu Jun 10 09:14:58.653552 2021] [proxy:debug] [pid 4186:tid 34504614656] proxy_util.c(3054): AH02824: FCGI: connection established with 127.0.0.1:9000 (*)
[Thu Jun 10 09:15:18.299256 2021] [proxy_fcgi:error] [pid 4186:tid 34504614656] (54)Connection reset by peer: [client this.is.my.ip:62429] AH01075: Error dispatching request to : (reading input brigade), referer: https://subw.somedomain.de/path/general.html
[Thu Jun 10 09:15:18.299303 2021] [proxy:debug] [pid 4186:tid 34504614656] proxy_util.c(2340): AH00943: FCGI: has released connection for (*)

We are talking about uploading currently relatively small files with less than 500kb that even do not work. Only very small files (somewhere between 63kb and 64kb is max) work.

Niels
Reply all
Reply to author
Forward
0 new messages