Page 1 of 1

[SOLVED] Moodle, Wordpress can't upload files / modsecurity limits the upload file size

Posted: Mon May 29, 2017 2:29 pm
by maxplay
Hey everyone, i hope someone can help me out, i'm going crazy with this...

i set a moodle site, works Ok, BUT: I can't upload large files, it seems that files over 120 KB are not loadded, the error in the moodle page says it could be the max_post_size in php.ini, but i already set this to higher values and phpinfo shows the correct values i entered.

My conf files are: snginx, nginx, sapache2, apache2
(http redirects to https, letsencrypt certificate)

phpinfo shows:

Code: Select all

PHP Version 7.0.18-0ubuntu0.16.04.1
Configuration File (php.ini) Path 	/etc/php/7.0/apache2
Loaded Configuration File 	/etc/php/7.0/apache2/php.ini 
post_max_size	15M
upload_max_filesize	10M
in moodle, loged in as a user with admin privileges, everytime i want to upload a file (for example image user profile) the error is (in spanish):

Code: Select all

El archivo subido puede que exceda la directiva max_post_size del php.ini.
URL:
null
Debug info:
null
Stack trace:
null
google translated: The uploaded file may exceed the max_post_size directive of php.ini

Already restarted apache2 and nginx, several times...

Hope someone can help!

thanks!

Re: moodle upload file size

Posted: Mon May 29, 2017 6:22 pm
by Trentor
In VestaCP panel, go to Server -> nginx -> Configure, and modify this accordingly to your needs:

Code: Select all

client_max_body_size
Suerte.

[SOLVED] Moodle, Wordpress can't upload files / modsecurity limits the upload file size

Posted: Tue May 30, 2017 1:49 am
by maxplay
Trentor, thanks for your post. I've done that and no effect at all.

I found the problem because i tested my uploads in a wordpress site, same server, and there's the problem again, "HTTP Error"
A few days ago i installed modsecurity, and in my modsecurity.conf:

Code: Select all

SecRuleEngine DetectionOnly
SecRuleEngine wasn't 'On', so i thought it wasn't applying changes to my traffic, but yes, it was...
i'm afraid as i didn't modify any else parameter, as:

Code: Select all

SecRequestBodyAccess On
then it was indeed limiting the upload size

So to quickly solve it (not thinking...sorry, i should read and test which option i must change); i did:

Code: Select all

# add one 0 to the end
SecRequestBodyLimit 131072000
# add 2  0's to the end
SecRequestBodyNoFilesLimit 13107200

# add 2   0's to the end
SecRequestBodyInMemoryLimit 13107200
maybe with "SecRequestBodyAccess off" it just did the trick, but i didn't test any further yet

So, briefly: the problem was not moodle or wordpress, neither php.ini nor nginx or apache, it was this modsecurity apache module that limits the body size or file upload size

--> so i changed the Subject of my original post in case it helps someone else

(the file upload limit was 128KB = 131072, before)

Thanks all,
maxplay