Apache proxy problem
-
Hello,
This week I received a notice from three users in the video section saying they can't upload videos. After doing some tests, I checked that if the video upload time is over 60 seconds, a connection error occurs between Apache and Peertube (NodeJS). The error is as follows:
[proxy:error] [pid xxx] (32)Broken pipe: [client xxx.xxx.xxx.xxx:59835] AH01084: pass request body failed to 127.0.0.1:9001 (127.0.0.1), referer: https://video.hardlimit.com/videos/uploadand then this one:
[proxy_http:error] [pid xxx] [client xxx.xxx.xxx.xxx:59835] AH01097: pass request body failed to 127.0.0.1:9001 (127.0.0.1) from xxx.xxx.xxx.xxx (), referer: https://video.hardlimit.com/videos/uploadRegarding the first error, sometimes this one appears and sometimes this other one:
[proxy:error] [pid xxx] (104)Connection reset by peer: [client xxx.xxx.xxx.xxx:58520] AH01084: pass request body failed to 127.0.0.1:9000 (127.0.0.1), referer: https://video.hardlimit.com/videos/uploadThe appearance of one or the other is random.
This looks like it's happening because of a timeout, so I added this to the Apache configuration:
Timeout 900 ProxyTimeout 900 KeepAliveTimeout 600But it doesn't solve anything. In the virtualhost configuration, I added timeouts to the proxy like this:
ProxyPass / http://127.0.0.1:9000/ timeout=600 ProxyPassReverse / http://127.0.0.1:9000/ timeout=600But nothing. Finally, I changed the kernel configuration parameter "/proc/sys/net/ipv4/tcp_fin_timeout" which coincidentally had a value of 60, but changing it to 120 didn't make any difference.
Looking at the logs, apparently this has been happening forever, but coincidentally, the vast majority of videos uploaded so far didn't exceed that upload time. I'm also not 100% sure that timeout used to be higher and that some update changed it. The truth is that it's too much of a coincidence that exactly 3 people complain the same week about the same thing, but anyway.
The Peertube people don't support Apache, so as a last desperate resort, I'll have to try with Nginx (something I honestly don't feel like doing at all). Before getting to that, if there's anyone here who is knowledgeable about Apache matters who can shed some light on this, I would greatly appreciate it.
-
Well, something has definitely changed in the last week. One of the affected users had uploaded videos in the past that took around half an hour to transfer. Looking at the APT logs (something I should have done before to stop suspecting Apache) I see that last Sunday I updated NodeJS, so it seems the perfect candidate for messing things up.
To fix it, in the end I installed Nginx, so from now on, all Hardlimit pages go through that web server. With this, the problem has been solved.
The reason I think it's solved is that when using Apache, when uploading a video, it was being copied as it was being received into the Peertube temporary folder. With Nginx, the file first goes into a server buffer and when it has finished being received, it is transferred to the Peertube temporary folder. That's why with Nginx there are no timeouts; because the internal transfer time is much shorter than the external one.
So with all this, I am 99% sure that it was the damn NodeJS update, where for some reason, they introduced a 60-second timeout for connections out of nowhere. And this is actually a bug, because in addition to annoying us the rebels who had preferred to avoid Nginx until now, the internal speed is also limited and in the end, the maximum file size will be the one that gives time to transfer in those 60 seconds.
-
You solve the problem, you uncover the mystery and on top of that you get involved in another project. What a guy
You end up seeing yourself learning Russian
Cheers! / Ура
-
For me Apache is always a mystery, when I have messed with it, and it's been a while, I never know how it has managed to work
