0

I am trying to upload a file using uppy. On my server I am using php 8.0 and Apache 2.

I am uploading a file which is about 156Mb in size but server returns response with 413 status code and no message.

As per instruction given on all over internet I tried to configure my php.ini file and here are the updated configurations

post_max_size = 20480M
upload_max_filesize = 20480M
max_execution_time = 24000
max_input_time = 24000
memory_limit = 800M

Unfortunately above settings didn't help me. I have confirmed the php.ini file location with following command

php -i | grep Conf

Apart from this, I came across an answer that asked to set SecRequestBodyLimit value in modsecurity.conf. modsecurity was not even installed in my system but still I installed it and set the SecRequestBodyNoFilesLimit value as SecRequestBodyLimit 1000000000 but no luck.

I highly doubt that this is from server and Uppy has no role in this issue but I cannot predict the exact problem.

fahad shaikh
  • 593
  • 1
  • 14
  • 29
  • 2
    In your index.php use [phpinfo](https://www.php.net/manual/en/function.phpinfo.php) to see if the rules got applied. Or debug with [ini_get](https://www.php.net/manual/en/function.ini-get.php) – F. Müller Nov 27 '22 at 10:06
  • 1
    20480M is a bit much, why not start out with a more normal value, like 50M, especially when you're [using a 32-bit PHP version](https://www.php.net/manual/en/ini.core.php#ini.post-max-size). – KIKO Software Nov 27 '22 at 10:09
  • @F.Müller I checked the output of `phpinfo()` and rules got applied. – fahad shaikh Nov 27 '22 at 10:19
  • @KIKOSoftware the file size was `156MB` so I updated the question. I set value as `200M` but still not working – fahad shaikh Nov 27 '22 at 10:23
  • Can you try testing with a basic file form element to 100% rule out uppy – Jacob Mulquin Nov 27 '22 at 10:48
  • @JacobMulquin I tried uploading the same file using basic form and it is returning the same `413` status code. – fahad shaikh Nov 27 '22 at 11:22
  • 1
    Maybe try with a simple text file or some bigger images and see, if it accepts these files just to see if the error is caused by something else. Are you the hoster or are you using managed hosting? If you use some containers it could be a memory issue or a restriction from the hoster. – F. Müller Nov 27 '22 at 21:30
  • @F.Müller I tried uploading 200+MB image multiple times but getting the following error `This looks like a network error, the endpoint might be blocked by an internet provider or a firewall.` I am self hoster and I do not use containers – fahad shaikh Nov 28 '22 at 04:32

1 Answers1

1

Response 413 is a typical error when you use ModSecurity, and the limit was set incorrectly. You should review the relevant documentation. If the size of your file is 156MB, you should calculate the base64 encoded size: multiply it with 4 and divide it by 3, so the approximate value is 208MB. I should set up 250MB for SecRequestBodyLimit, but not for SecRequestBodyNoFilesLimit - please keep it as low. 250MB is 262144000 byte, so try to set up this:

SecRequestBodyLimit 262144000

Also please check your Apache's error.log, you have to see every relevant information there.

airween
  • 6,203
  • 1
  • 14
  • 20
  • I set `SecRequestBodyLimit` as 262144000 but that didn't help. Apache's `error.log` had no logs. I was receiving the error even when `modsecurity` was not installed on my server – fahad shaikh Nov 28 '22 at 09:27
  • Oh, sorry for my mistake, I didn't realized that the error occurred when ModSec wasn't installed. But that's very odd, that you don't have any error.log. You should take a look to documentation: https://httpd.apache.org/docs/2.4/logs.html#errorlog – airween Nov 28 '22 at 14:01