Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dokku (Digital Ocean) client_max_body_size node.js

So I've just pushed my app to Dokku (Digital Ocean) - and get the following error returned from an ajax post:

POST http://example.com/foo 413 (Request Entity Too Large)

A quick google shows this problem is due to client_max_body_size being too low. So I've SSH'd into the server, opened up the apps nginx.conf and increased it as per instructions here:

client_max_body_size 100M;

https://github.com/progrium/dokku/issues/802

However, I still have the same problem... Do I need to restart a process or something? I tried restarting the dokku app - but all this did was to overwrite my nginx.conf file.

like image 373
Rob Avatar asked Dec 08 '22 01:12

Rob


1 Answers

@Rob s answer is correct, but has the problem that the changes are not persisted, because the nginx.conf might become regenerated e.g. when deploying.

The solution I use is outlined in this github commit https://github.com/econya/dokku/commit/d4ea8520ac3c9e90238e75866906a5d834539129 .

Basically, dokkus default nginx templates include every file in the nginx.conf.d/ subfolder into the main server configuration block, thus

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

Will create a file that is merged into the nginx.conf (at nginx startup time I believe) and kept untouched by dokku as long as you do not use interfering plugins or define another nginx template (as of 2017/08).

like image 167
Felix Avatar answered Dec 11 '22 11:12

Felix