Thursday, September 5, 2019

centos - File uploads > 100KB hang with no apache errors



Originally posted on stackoverflow, but deleted and moved here.



Apache 2.4.6 -- PHP 7.0 -- CentOS 7




VM Memory: 8GB -- CPUs: 2 -- Available HD: about 200GB



Having a strange problem where file uploads over 100KB just sit there and hang, doing nothing.



I have increased all the relevant config settings numerous times, as high as 2GB for upload size and post max, and nothing has made any difference.



Files <= 100KB upload instantly, but a 200KB file just sits there.







Here is the test script I am using at the moment:



ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('html_errors', 1);
error_reporting(E_ALL);

echo 'file_uploads: ' . ini_get('file_uploads') . '
';

echo 'max_execution_time: ' . ini_get('max_execution_time') . '
';
echo 'memory_limit: ' . ini_get('memory_limit') . '
';
echo 'post_max_size: ' . ini_get('post_max_size') . '
';
echo 'upload_max_filesize: ' . ini_get('upload_max_filesize') . '
';
echo 'max_input_time: ' . ini_get('max_input_time') . '
';


if (isset($_FILES['file'])){
print_r($_FILES['file']);
}

?>






Select image to upload:












Here is the list of config settings, as printed out in the script:




file_uploads: 1
max_execution_time: 120
memory_limit: 512M
post_max_size: 100M
upload_max_filesize: 100M
max_input_time: 120






There is nothing printed to the httpd error logs after I attempt an upload.



This is the error_log, after restarting httpd:



[Mon Jul 30 10:11:33.843669 2018] [mpm_prefork:notice] [pid 3811] AH00170: caught SIGWINCH, shutting down gracefully
[Mon Jul 30 10:11:35.103671 2018] [core:notice] [pid 3897] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Mon Jul 30 10:11:35.105963 2018] [suexec:notice] [pid 3897] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.8.6.155. Set the 'ServerName' directive globally to suppress this message
[Mon Jul 30 10:11:35.168442 2018] [auth_digest:notice] [pid 3897] AH01757: generating secret for digest authentication ...
[Mon Jul 30 10:11:35.170108 2018] [lbmethod_heartbeat:notice] [pid 3897] AH02282: No slotmem from mod_heartmonitor

[Mon Jul 30 10:11:35.356666 2018] [mpm_prefork:notice] [pid 3897] AH00163: Apache/2.4.6 (CentOS) PHP/7.0.30 configured -- resuming normal operations
[Mon Jul 30 10:11:35.356845 2018] [core:notice] [pid 3897] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'


And this is the error_log after trying to upload a 200KB file, after the process eventually crashes and I get an error page in the browser (I don't get a 500 error or anything, just "This page isn't working. The page didn't send any data. ERR_EMPTY_RESPONSE"):



[Mon Jul 30 10:11:33.843669 2018] [mpm_prefork:notice] [pid 3811] AH00170: caught SIGWINCH, shutting down gracefully
[Mon Jul 30 10:11:35.103671 2018] [core:notice] [pid 3897] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Mon Jul 30 10:11:35.105963 2018] [suexec:notice] [pid 3897] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.8.6.155. Set the 'ServerName' directive globally to suppress this message

[Mon Jul 30 10:11:35.168442 2018] [auth_digest:notice] [pid 3897] AH01757: generating secret for digest authentication ...
[Mon Jul 30 10:11:35.170108 2018] [lbmethod_heartbeat:notice] [pid 3897] AH02282: No slotmem from mod_heartmonitor
[Mon Jul 30 10:11:35.356666 2018] [mpm_prefork:notice] [pid 3897] AH00163: Apache/2.4.6 (CentOS) PHP/7.0.30 configured -- resuming normal operations
[Mon Jul 30 10:11:35.356845 2018] [core:notice] [pid 3897] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'


So nothing new has been added to the error_log. I don't know if any of those startup errors are relevant or not, but I get a few of those on other centos servers whose uploads work fine.







I have tried:




  • Changing the config settings in php.ini and in the script itself

  • Removing php 7.2 and installing php 7.0

  • Removing httpd and reinstalling

  • Checking to make sure there is no LimitRequestBody in any of the apache conf files

  • Setting the tmp upload directory to /tmp

  • Completely disabling selinux

  • Rebooting the whole machine




It sounds very similar to this: https://stackoverflow.com/questions/6970317/uploading-100kb-zip-files-gives-an-internal-server-error



But I do not have mod_fcgid installed.



Here is my full phpinfo: https://files.fm/u/dthwdvna



I'm at a total loss now. I don't know if i've overlooked something really simple, or if it's a complicated problem, but I'm running out of ideas other than re-creating the entire server.




This was a blank CentOS 7 minimal installation, with yum install httpd, etc... which I've done numerous times on other servers and never run into this issue.


Answer



Never really worked out exactly what the issue was, but switching from using an IP address to an internal domain seemed to fix it, so it was something on the network somewhere, though no idea what.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...