dokku: 413 Request Entity Too Large
Asked Answered
C

2

6

I keep getting the "413 Request Entity Too Large" error when uploading files that are larger than 1M. I followed the following instructions from here but it didn't work.

mkdir /home/dokku/myapp/nginx.conf.d/
echo 'client_max_body_size 50M;' > /home/dokku/myapp/nginx.conf.d/upload.conf
chown dokku:dokku /home/dokku/myapp/nginx.conf.d/upload.conf
service nginx reload

I tried updating my Procfile adding a php.ini file to my root directory with the following entry but it also didn't help:

Procfile:

web: vendor/bin/heroku-php-nginx -C nginx.conf -i php.ini php/

php.ini:

upload_max_filesize = 100M
post_max_size = 100M

What am I doing wrong? Is there anyway to test if my configurations are being used or if they are being overwritten by something else? I checked phpinfo(); and those setting are being used, is there an equivalent to that for nginx?

Is there a way to change the nginx settings globally for all images?

Cilo answered 28/9, 2017 at 1:42 Comment(1)
what do nginx log say? And possible for you to check if nginx had that setting applied by running nginx -T on the machine where nginx is runningDetradetract
L
15

Dokku's default nginx config limits the client max body size to to 1MB.

You can reconfigure this by:

mkdir /home/dokku/node-js-app/nginx.conf.d/
echo 'client_max_body_size 50m;' > /home/dokku/node-js-app/nginx.conf.d/upload.conf
chown dokku:dokku /home/dokku/node-js-app/nginx.conf.d/upload.conf
service nginx reload

Where node-js-app is the app name. See http://dokku.viewdocs.io/dokku/configuration/nginx/#customizing-via-configuration-files-included-by-the-default-tem

Lutestring answered 14/6, 2018 at 17:35 Comment(1)
Thank's I tried to set with nginx:set <app> <property> (<value>) but it's not possible. Your solution is correct.Hadsall
H
0

I'm using dokku version 0.34.3, and now the answer frmdstryr posted is no longer valid. The current version dokku can be configured like this:

dokku nginx:set your-app client-max-body-size 50m

This enabled my rails app to work with carrierwave upload and so on.

Hickman answered 7/4 at 14:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.