Developing software in the Real World

Custom URLs for a Cloud Foundry application

Now that I have my application deployed to Cloud Foundry, I need it to work with my own domain, such as bookshelf.akrabat.com rather than slim-bookshelf.eu-gb.mybluemix.net. We can do this via the command line which is useful.

To do this we need to create a domain and then we can create a route.

Create a domain

To create a domain, we use the command cf create-domain {organisation name} {domain name}. For me, my organisation is "19FT", so this is the command I use:

Now that we have a domain we can map a unique route to our application.

Mapping a route

Unsurprisingly, we use the map-route argument to create a route via the command line. This is needs to know which app we want to map to and then we can choose to add a sub domain (e.g. bookshelf.akrabat.com) and a path (e.g. akrabat.com/slimbookshelf). We can even combine the two for something like slim.akrabat.com/bookshelf if we wanted to.

The full command is cf map-route {app name} {domain name} --hostname {hostname} --path {path}, so for this example I use:

We're all done with the Cloud Foundry side. The last thing we need to do is set up a DNS record.

Set up DNS

To make everything work, create a CNAME DNS record from your route to the provider's domain for your application (Bluemix in this case). Hence, I create this in my bind configuration:

That's it! Our own domain will now work with our shiny Cloud Foundry hosted application.

Leave a Reply

Your email address will not be published. Required fields are marked *