9

I need to increase the client_max_body_size setting for a single app I have installed on a Dokku Paas. I could edit the nginx configuration globally, but that would be brittle, and I would like this setting to live with the app config where possible.

I have seen some plugins that help rewrite the nginx.conf file (eg. https://github.com/mikexstudios/dokku-nginx-alt), but that seems like overkill when I only want to change a single setting.

I have also noticed the nginx-configure plugin hook (https://github.com/progrium/dokku/pull/189), but I could not find clear instructions on how to use this from an app (where would I put the hook script, for example?).

What is the cleanest, most maintainable and most portable method of setting a single nginx configuration parameter on a per app basis?

flightlessbird
  • 413
  • 3
  • 9
  • And what's the problem? This directive could be used anywhere – Alexey Ten Aug 27 '14 at 17:50
  • Sorry - I don't follow. What directive? My question is how do I set a particular nginx setting on per app basis. – flightlessbird Aug 28 '14 at 11:59
  • nginx knows nothing about your app. Nginx works in terms on `server` and `location` blocks. Somewhere you have location block, that pass request to you app. You could add `client_max_body_size` directive to that block. – Alexey Ten Aug 28 '14 at 12:09
  • Did you see that this is specifically a question about dokku? I know how to configure this myself, but this is running in a PAAS environment where the nginx configuration is automatically generated. Thanks for your help though! – flightlessbird Aug 28 '14 at 12:37
  • I found this plugin which is using perl to modify the nginx.conf after deploying: https://github.com/fabiooshiro/dokku-client-max-body-size/blob/master/nginx-pre-reload You could conditionally modify the file per app (e.g. when a certain file in the app directory exists) – chmanie Sep 29 '14 at 21:54

1 Answers1

19

This question is a bit old, but I ran into it while searching for a solution to the same question.

By default, dokku sites are installed in /home/dokku/{site-name}.

There is one main nginx file per app in this folder, nginx.conf. This file will be replaced every time you deploy so you don't want to change this.

However, you will see that this main nginx.conf file has the following line it in -

  include /home/dokku/{site-name}/nginx.conf.d/*.conf;

Which will include any .conf files in the nginx.conf.d folder.

So you can add a file called upload.conf (for example) to the nginx.conf.d folder, containing just client_max_body_size 50M;, and you'll achieve what you want to do.

After you create the directory and config file, ensure you chown them to the dokku user.

See https://github.com/dokku/dokku/blob/master/docs/configuration/nginx.md for further details.

Jonathan
  • 8,453
  • 9
  • 51
  • 74
RYFN
  • 2,939
  • 1
  • 29
  • 40