Dokku (Digital Ocean) client_max_body_size node.js
Asked Answered
S

3

5

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.

Saloop answered 20/8, 2015 at 20:17 Comment(0)
I
6

This has been updated in Dokku and can be done from the CLI: dokku nginx:set node-js-app client-max-body-size 50m. https://dokku.com/docs/networking/proxies/nginx/#specifying-a-custom-client_max_body_size

Irrefragable answered 9/9, 2021 at 13:20 Comment(1)
After doing this I needed to run dokku proxy:build-config node-js-app as wellIdiomatic
F
16

@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).

Fuchsia answered 22/8, 2015 at 13:58 Comment(0)
I
6

This has been updated in Dokku and can be done from the CLI: dokku nginx:set node-js-app client-max-body-size 50m. https://dokku.com/docs/networking/proxies/nginx/#specifying-a-custom-client_max_body_size

Irrefragable answered 9/9, 2021 at 13:20 Comment(1)
After doing this I needed to run dokku proxy:build-config node-js-app as wellIdiomatic
S
0

I figured it out - I had to cd into the apps directory (as per github instructions: https://github.com/progrium/dokku/issues/802

The right file to modify is /home/dokku//nginx.conf and as @dipankar mentioned, you should add a client_max_body_size 20M; line to the server scope.

and then I typed

reload nginx

into the command line. All works :)

Saloop answered 20/8, 2015 at 20:29 Comment(2)
If anyone knows how I can persist these settings between deploys - that would be great!Saloop
See my answer above ;)Fuchsia

© 2022 - 2024 — McMap. All rights reserved.