How to change Default App in Dokku for Domain Host Name
Asked Answered
K

1

5

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.

Karlotta answered 13/10, 2015 at 6:8 Comment(0)
S
9

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 [email protected]: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:

Sinew answered 13/10, 2015 at 11:24 Comment(1)
Excellent! Thanks. I went for option 3 as it would send all unknown hosts to my main app. Thanks again!Karlotta

© 2022 - 2024 — McMap. All rights reserved.