Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set nginx configuration settings on a per app basis in Dokku?

Tags:

nginx

dokku

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?

like image 374
flightlessbird Avatar asked Aug 27 '14 14:08

flightlessbird


1 Answers

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.

like image 171
RYFN Avatar answered Oct 13 '22 09:10

RYFN