How to add a custom 404 page to nginx app on dokku

Posted July 1, 2015 6.9k views

Wondering if it is possible to customize the 404 page displayed for a dokku app.

For example, if is a working nginx app, can I point to something like

nginx v1.6.2
dokku v0.2.3

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
3 answers

You could edit your vhost to use a 404 page. Edit a vhost something like this:

    root    /srv/www/foo/public_html;
    expires     1M;
    access_log  /srv/www/foo/logs/access.log;
    error_log   /srv/www/foo/logs/error.log;

    error_page 404 /404.html;

    location / {
        index   index.html;
        rewrite ^/(.*)/$ /$1 permanent;
        try_files "${uri}.html" $uri $uri/ =404;

    location = /404.html {
  • Sorry to be dense, but what is the path to the vhost? I found /home/dokku/<app-name>/nginx.conf but that gets overwritten on each push. Also found /home/dokku/VHOST but that only has the domain in it.

Allright, to customize the nginx template in use for the myapp application, create a file at /home/dokku/<appname>/nginx.conf.template with the default contents.
Edit this file to your needs, so use your custom 404 page error etc.
After your changes a dokku deploy <myapp> will regenerate the /home/dokku/<appname>/nginx.conf file which is then used.

I hope this will work for you

Thanks. My version of dokku is 0.2.3, looks like this functionality was added in 0.3.10. I will update and then try this!

For others who might find this: