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.
@Rob s answer is correct, but has the problem that the changes are not persisted, because the nginx.conf might become regenerated eg 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).
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
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 :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.