HTTP 413: Request too large

1.3k views Asked by At

Using Apache 2.4 & PHP 7.4 on Ubuntu 18.04. Default Apache conf file. I'm trying to upload ~700 jpegs (totaling ~100MB, largest one being ~1MB) to a Laravel app, for a single one it works but for the larger request size I get:

The server returned a "413 Payload Too Large".

Site config looks like:

<VirtualHost *:443>
    ServerName server.domain.com

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    RequestHeader set X-Forwarded-Proto "https"
    RequestHeader set X-Forwarded-Port "443"

    ProxyPreserveHost On
    ProxyPass "/" "http://127.0.0.1:8000/"
    ProxyPassReverse "/" "http://127.0.0.1:8000/"

    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/privkey.pem
    LogLevel debug
</VirtualHost>

/etc/php/7.4/apache2/php.ini has:

max_execution_time = 3600
max_input_time = 3600
memory_limit = 512M
post_max_size = 0 #Unlimited
file_uploads = On
upload_max_filesize = 100M
max_file_uploads = 2000

I've restarted Apache after applying. I see the POST request in my access.logs:

"POST /i/import/job/11c1893c-d775-46d7-9df8-1a6fafcc96f2/1 HTTP/1.1" 413 1562

and (normal looking) debug logs in error logs:

[ssl:debug] [pid 5395] ssl_engine_kernel.c(415): [client ip:1027] AH02034: Initial (No.1) HTTPS request received for child 7 (server server.domain.com:443), referer: https://server.domain.com/i/import/job/11c1893c-d775-46d7-9df8-1a6fafcc96f2/1
[authz_core:debug] [pid 5395] mod_authz_core.c(845): [client ip:1027] AH01628: authorization result: granted (no directives), referer: https://server.domain.com/i/import/job/11c1893c-d775-46d7-9df8-1a6fafcc96f2/1
[proxy:debug] [pid 5395] mod_proxy.c(1253): [client ip:1027] AH01143: Running scheme http handler (attempt 0), referer: https://server.domain.com/i/import/job/11c1893c-d775-46d7-9df8-1a6fafcc96f2/1
[proxy_fcgi:debug] [pid 5395] mod_proxy_fcgi.c(1019): [client ip:1027] AH01076: url: http://127.0.0.1:8000/i/import/job/11c1893c-d775-46d7-9df8-1a6fafcc96f2/1 proxyname: (null) proxyport: 0, referer: https://server.domain.com/i/import/job/11c1893c-d775-46d7-9df8-1a6fafcc96f2/1
[proxy_fcgi:debug] [pid 5395] mod_proxy_fcgi.c(1024): [client ip:1027] AH01077: declining URL http://127.0.0.1:8000/i/import/job/11c1893c-d775-46d7-9df8-1a6fafcc96f2/1, referer: https://server.domain.com/i/import/job/11c1893c-d775-46d7-9df8-1a6fafcc96f2/1
[proxy:debug] [pid 5395] proxy_util.c(2325): AH00942: HTTP: has acquired connection for (127.0.0.1)
[proxy:debug] [pid 5395] proxy_util.c(2379): [client ip:1027] AH00944: connecting http://127.0.0.1:8000/i/import/job/11c1893c-d775-46d7-9df8-1a6fafcc96f2/1 to 127.0.0.1:8000, referer: https://server.domain.com/i/import/job/11c1893c-d775-46d7-9df8-1a6fafcc96f2/1
[proxy:debug] [pid 5395] proxy_util.c(2588): [client ip:1027] AH00947: connected /i/import/job/11c1893c-d775-46d7-9df8-1a6fafcc96f2/1 to 127.0.0.1:8000, referer: https://server.domain.com/i/import/job/11c1893c-d775-46d7-9df8-1a6fafcc96f2/1
[proxy:debug] [pid 5395] proxy_util.c(3054): AH02824: HTTP: connection established with 127.0.0.1:8000 (127.0.0.1)
[proxy:debug] [pid 5395] proxy_util.c(3240): AH00962: HTTP: connection complete to 127.0.0.1:8000 (127.0.0.1)
[proxy:debug] [pid 5395] proxy_util.c(2340): AH00943: http: has released connection for (127.0.0.1)
[ssl:debug] [pid 5395] ssl_engine_io.c(1102): [client ip:1027] AH02001: Connection closed to child 7 with standard shutdown (server server.domain.com:443)

I don't see anything related in my application logs. Also tried setting LimitRequestBody in the apache2.conf but didn't help either.

1

There are 1 answers

0
baarkerlounger On BEST ANSWER

Artisan Serve - which the Laravel app is using to start the server, using the php.ini at php-cli not the one at php-apache or php-fpm modifying the config in that, resolved this.