Pragmatism 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 rather than 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:

$ cf create-domain 19FT
Creating domain for org 19FT as

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. and a path (e.g. We can even combine the two for something like 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:

$ cf map-route slim-bookshelf --hostname bookshelf
Creating route for org 19FT / space demo as
Adding route to app slim-bookshelf in org 19FT / space demo as

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:

bookshelf IN CNAME

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