In the part 1 of the tutorial we have seen how to setup a Ghost Blog for free on OpenShift Cloud Platform. But the OpenShift domain is not so cool... so let's see how to setup a custom domain for your blog.
The first thing to do is to obtain a domain name, you can buy it or use one of free TLD. I will use the free .ml domain available by freenom. So sign up to freenom and register a new domain. I've chosen h4t0n.ml.
This is my freenom administration page. You could see something similar.
Now we have to configure the DNS record to point to the OpenShift URL. But before it let's configure the custom domain on the OpenShift Ghost Application. For my testing blog I want to use the blog.h4t0n.ml URL. So login to OpenShift, select the Ghost App and click to change URL as shown below.
Now insert your custom domain name, blog.h4t0n.ml is mine.
As shown by OpenShift, its time to configure the DNS record but don't worry it is very simple.
Return to your custom domain DNS Management service, in my case is freenom, and add the CNAME record from your custom domain to the OpenShift domain.
It may take some time due to the DNS propagation (use this service to check the status of your domain names).
Now my blog is available at blog.h4t0n.ml, but the Ghost Application don't know this and all its internal links point to myblog-h4t0n.rhcloud.com.
To resolve this issue we have to change the production configuration of Ghost: we have to clone the source code Ghost Repository, modify the config file and commit/push the changes. Let's do it, first of all clone the source code from OpenShift (you have to configure a public key for your local machine the first time you clone a repo coming from OpenShift, use the OpenShift ssh tutorial for your target system).
Now open the config.js file with your best editor and change the production url accordingly to your database environment.
Commit, push changes and wait the OpenShift Blog restart.
Once restarted, your blog is fully ready to use your custom domain name. Enjoy it !!!!