Pop quiz, which URL is prettier:
Exactly, the first one. To setup a custom domain name you need to buy a domain and then register DNS records to point to your AppCloud cluster. This is (to me) a convoluted process. It could be much simpler.
ey-dns command line application to make DNS simple (see the readme). It supports 6 different DNS services, including DNSimple and AWS Route 53 (see below).
It’s really quite easy to use:
- Install the tool:
$ gem install engineyard-dns
- Change to your Rails/Ruby project that is deployed with AppCloud:
$ cd path/to/my/app
$ ey-dns assign myapp.com Assigning myapp.com —> 220.127.116.11 (drnic/myapp_production) Assigning www.myapp.com —> 18.104.22.168 (drnic/myapp_production)
If you have previously assigned the domain records to another IP address, it will prompt you to change them.
If there is any confusion about which AppCloud environment is hosting your application, it will show you your options and then you can use the
--account options to be more specific:
$ ey-dns assign myapp.com --environment myapp_production
(Subdomains are a little weird because of how DNS zones work. Put your bare domain first and then subdomain names after. The following sets staging.myapp.com to the myapp_staging environment.)
$ ey-dns assign myapp.com staging --environment myapp_staging
If you have multiple apps on one environment, you will still have to update the domain name of each app in the AppCloud dashboard so that nginx knows what vhost you mean to serve at that domain. Just click edit on each app in an environment to add vhost domains.
Preparing your DNS provider
To be complete you will also need to purchase/transfer a domain:
- Register your application’s domain with a DNS provider (see supported list below), such as DNSimple.
- Transfer your domain to your DNS provider or change to use their name servers, such as
ns1.dnsimple.com(ns2, ns3, etc) for DNSimple.
Supported DNS providers
ey-dns will automatically determine which DNS provider is managing the domain/zone that you are wiring up to your AppCloud environment.
This new CLI uses fog to access DNS providers. The current list of available DNS providers for fog is: AWS, Bluebox, DNSimple, Linode, Slicehost, Zerigo. The next section shows how to setup fog credentials.
To access your DNS provider, you need to add your account/API credentials into your
In my example
~/.fog file below I have DNS access to DNSimple, Slicehost and AWS Route 53.
:default: :dnsimple_email: MYEMAIL :dnsimple_password: XXXXXXXXXXX :aws_access_key_id: 0NJRCXXXXXXXXXXXX :aws_secret_access_key: QGtnbXXXXXXXXXXXX/qQ4lXXXXXXXXXXXXXX :slicehost_password: f9a265f66XXXXXXXXXXXXXXXXXXXXXXXXXXX
I currently use DNSimple for registering and serving all my new domains. Their API credentials are the same email/password you use to login to the service.
Note the surreptitious referral used here, giving me a free month for each DNSimple sign-up, bwhahahaha. To avoid gifting me a free month, use http://dnsimple.com link. A free month isn’t as cool as free swag, but I don’t think DNSimple has free swag. Well, I don’t have any of it.
Recently AWS began offering an API-driven DNS server Route 53. The AWS credentials for access DNS are the same credentials you use in CarrierWave or PaperClip to access AWS S3. To find them, log into your AWS Account and navigate to “Security Credentials”, then “Access Credentials”, and click “Show” to see your secret access key.
Until I switched to DNSimple and to fog, I used Slicehost for its API/CLI-driven DNS. I still have many domains managed by Slicehost. To enable API access to your Slicehost account in
fog (and hence
ey-dns) go to https://manage.slicehost.com/api, enabled API access and copy your API token into the
slicehost_password field of
You can test your DNS credentials with the
ey-dns domains command:
$ ey-dns domains AWS: none DNSimple: drnicwilliams.com - 0 records emrubyconf.com - 2 records mocra.com - 27 records Slicehost: myconfplan.com. - 0 records
Hopefully this tool makes it much easier to setup or change DNS for your AppCloud environments. Let us know in the comments or in the project’s Issues if you love it, find bugs or have feature requests.
The source and instructions for the project is available on GitHub.