digital-oceandokku

How to change Default App in Dokku for Domain Host Name


As a personal project I've deployed the Dokku Image on Digital Ocean and got everything working well. In fact it works very well as I've done it before, but I have a question on how I can change what "default" app the Domain Host Name points to.

Here is my setup.

  1. I set up Dokku on Digital Ocean with the "Hostname" and "Virtualhost Naming" options selected. So basically this means that I have my own Domain Name being used to point to apps instead of the IP/Port. Lets assume my Domain Name is mydomain.com

  2. I have 2 Dokku apps running in this Digital Ocean server. Lets call them app-a and app-b. As I enabled "virtual naming" these apps can be accessed like so.

    • app-a.mydomain.com
    • app-b.mydomain.com

All this works perfectly.

Now I notice that if I go to "mydomain.com" or "www.mydomain.com" in the browser it "defaults/redirects with masking" to "app-b.mydomain.com". My guess is that because app-b was the last App I set up NGINX has defaulted to this.

So how can I change this behaviour, i.e. I need "mydomain.com" or "www.mydomain.com" to go to app-a instead?

Thanks very much in advance.

Mark.


Solution

  • By default, dokku will route any received request with an unknown HOST header value to the lexicographically first site in the nginx config stack.

    I believe you can add root domain using domains plugin

    # add a domain to an app
    dokku domains:add app-a mydomain.com
    

    or

    You can also specify fully qualified names as the name of the app

    $ git remote add dokku dokku@dokku.me:mydomain.com
    $ git push dokku master
    

    or

    Alternatively, you may push an app to your dokku host with a name like "00-default". As long as it lists first, it will be used as the default nginx vhost.


    References: