As I started to use OpenShift more and more for my own application hosting, I was always curious to know that how do I get my OpenShift URL to look like the domain name I just bought. While it is great that openshift let you create your own <appname>-<domainname>.rhcloud.com, when you want to show your app to the world you want might your own domain name.
Now here comes the part where things get interesting. I need to associate my mycustomdomain.com (my own domain) DNS name with my OpenShift url blog-cloudbuzz.rhcloud.com. The key to understanding how to do this is to understand CName records in DNS. The basic idea with a CName record is that one name (mycustomdomain.com) points to another name (blog-cloudbuzz.rhcloud.com). If you want to forward over your whole domain, such as mycustomdomain.com and not www.mycustomdomain.com, then you either need to use Domain Forwarding or find a DNS provider that allows “Naked” CName records. Domain forwarding uses a web server to do a redirect.
“Naked domains” is a term for a URL without the ‘www’. e.g. ‘mycustomdomain.com’ is a naked domain and ‘www.mycustomdomain.com.com’ is not a naked domain.
The initial setback was that ‘naked domains’ are against RFC rules; the good news however is ‘CNAME flattening‘ bypasses the restriction of RFC DNS specifications. Who does ‘CNAME flattening’ you might ask?! Well, I personaly prefer CloudFlare because its very easy to confirgure and use. Follow the below steps to get started and redeem hours and hours of pain.
Head over to cloudflare.com and sign up.
Type your website URL without the ‘www’ and click “Add Website”. And point your GoDaddy’s domain name’s DNS name to point to CloudFlares.
CloudFlare will add you new entry and start to scan your websites DNS records.
Change the CNAME records to something similar to this. Kindly user your details like OpenShift URL and related IP address.
Sleep, let the changes simmer over night for the changes to take affect. 24 hours minimum. Most of the cases it will be done within 30 mins but maximum is 24 hrs.
Open CNAME record for your domain and update name server details as follows.
1. Log in to your GoDaddy account.
2. From the Products menu, click Launch next to Domains.
3. Tick the box next to the domain you are going to manage.
4. Hover over the Nameservers link in the menu and select Set Nameservers
5. Choose Custom and click on Enter custom nameservers.
6. Now you can place the mycustom domain nameservers into the two fields below. These will be chad.ns.cloudflare.com and chan.ns.cloudflare.com (might differ in your case, kindly refer your cloudflare account once)
Then click OK and then Save
Set alias in OpenShift to mycustomdomain.com
Make sure GoDaddy DNS record doesn’t have any conflicting
A record set up.
Let it simmer for some time and all of the original desired behaviour should be working.