minh.n
By:
minh.n

Dokku and Subdomain forwarding

September 1, 2014 1.8k views

Hello. I'm a bit new to all this so please bare with me.
I've set up Dokku with a very simple rails app following:
https://www.digitalocean.com/community/tutorials/how-to-use-the-dokku-one-click-digitalocean-image-to-run-a-ruby-on-rails-app

The app is toy-app and I've set Dokku to use subdomain like this tutorial:
https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-dokku-application

My zone file is:

$TTL    1800
@       IN  SOA NS1.DIGITALOCEAN.COM.   hostmaster.minhn.net. (
            1409595135 ; last update: 2014-09-01 18:12:15 UTC
            3600 ; refresh
            900 ; retry
            1209600 ; expire
            1800 ; ttl
            )
             IN      NS      NS1.DIGITALOCEAN.COM.
                     NS      NS2.DIGITALOCEAN.COM.
                     NS      NS3.DIGITALOCEAN.COM.
@   IN A    107.170.189.247
*.minhn.net IN A    107.170.189.247
toy-app IN A    107.170.189.247
sample-app  IN A    107.170.189.247
*.toy-app   CNAME   toy-app.minhn.net.
*.sample-app    CNAME   sample-app.minhn.net.

I plan on having another app called sample-app and have sample-app.minhn.net go to that app. I want my minhn.net to lead to no where for now. But right now minhn.net and sample-app.minhn.net both goes to toy-app.minhn.net.

Why is this? Is it because the * A record I have? I thought that just meant anything before minhn.net would be forward to the ip but then dokku would check if it matches the subdomain name, if not it won't serve the app?

Thanks for your time.

1 comment
  • Quick update. I've removed the * A and now my zone file is:

    $TTL    1800
    @       IN  SOA NS1.DIGITALOCEAN.COM.   hostmaster.minhn.net. (
                1409606114 ; last update: 2014-09-01 21:15:14 UTC
                3600 ; refresh
                900 ; retry
                1209600 ; expire
                1800 ; ttl
                )
                 IN      NS      NS1.DIGITALOCEAN.COM.
                         NS      NS2.DIGITALOCEAN.COM.
                         NS      NS3.DIGITALOCEAN.COM.
    @   IN A    107.170.189.247
    toy-app IN A    107.170.189.247
    sample-app  IN A    107.170.189.247
    *.toy-app   CNAME   toy-app.minhn.net.
    *.sample-app    CNAME   sample-app.minhn.net.
    

    and the same thing still occurs. sample-app.minhn.net and minhn.net both goes to toy-app.minhn.net*

    *which I'm not sure if that's an accurate way to portray it, dokku tells me the app is accessible at toy-app.minhn.net so I'm just assuming that's where it's at. It could be at minhn.net and the other two subdomain is being redirected to the main one?

1 Answer

You need to modify the Virtual Host config file for toy-app, and put this in:

ServerName toy-app.minhn.net
ServerAlias toy-app.minhn.net

above < Directory >

Also, do the same for all other vhosts. When hosting more than one domain, it needs to know which vhost the config is for, or it goes to the default

If that doesn't work, and you're running CentOS/Fedora, edit /etc/httpd/conf/httpd.conf and uncomment

NameVirtualHost 80

reload/restart apache2/httpd, and you should be good.

Have another answer? Share your knowledge.