Hi,

In this article we will discuss about aliasing our application on OpenShift. A website alias is a way to link one domain name to another or in siple words.. a website alias is a nickname for a website.

For eg: The domains mytest.net and mytest.com have been registered by a company, entering either in a web browser will find the same content.

There are few resons for using web aliases :

1. Handle common misspellings : a user might incorrectly type a URL, for example, mtest.com instead of mytest.com. Organizations often register commonly misspelled versions of their domains and point them to the correct URL.

2. Re-branding : an organization may purchase another organization and choose to re-brand the domain name or multiple domains (organizationA.org and organizationB.org become organizationC.org.) Viewers likely will continue to use the old bookmarks that will send them to the new site.

3. At times developers come up with some idea to create a web-site and later want to fork it as per requirement.

4. Direct viewers to a different page.

So lets see, how to to do this in openshift :

Step-1 : Assuming that you have an application running on openshift, we will run below command :

$ rhc domain show

for eg :

..
[userone@userone OpenShift]$ rhc domain show
Password: ********


User Info
=========
Namespace: userone
  RHLogin: userone@blah.com


Application Info
================
kitchensink
    Framework: jbossas-7
     Creation: 2012-07-16T05:40:14-04:00
         UUID: cdw8a6h5ju12345u7894561230f5y9w
      Git URL: ssh://cdw8a6h5ju12345u7894561230f5y9w@kitchensink-userone.rhcloud.com/~/git/kitchensink.git/
   Public URL: http://kitchensink-userone.rhcloud.com/

Above command shows one existing application kitchensink with existing openshift account.

Step-2 : Lets add alias to it :

rhc-ctl-app -a $ApplicationName -c add-alias –alias www.youralias.com

for eg:

[userone@userone OpenShift]$ rhc-ctl-app -a kitchensink -c add-alias --alias www.myalias.com
Password: ********


RESULT:
Success
..

Note : Make sure you own the domain name that you are adding. You can check www.domain.com, www.godaddy.com, www.bigrock.in, www.joker.com etc .to get you own domain.

Step-3 : Now let us confirm it has been added :

$ rhc domain show

for eg:

..
[userone@userone OpenShift]$ rhc domain show
Password: ********


User Info
=========
Namespace: userone
  RHLogin: userone@blah.com


Application Info
================
kitchensink
    Framework: jbossas-7
     Creation: 2012-07-16T05:40:14-04:00
         UUID: cdw8a6h5ju12345u7894561230f5y9w
      Git URL: ssh://cdw8a6h5ju12345u7894561230f5y9w@kitchensink-userone.rhcloud.com/~/git/kitchensink.git/
   Public URL: http://kitchensink-userone.rhcloud.com/
      Aliases: www.myalias.com

 Embedded: 
      None

Step 4 : Above we can see we have an alias added as “www.myalias.com”. Now try to hit the url from web-browser, it should work 🙂

Adding multiple aliases :

You can add multiple aliases to same application using the same command mentioned in Step-2.

Removing aliases :

To remove your aliases you can run below command :

$ rhc-ctl-app -a $ApplicationName -c remove-alias –alias www.youralias.com

for eg:

..
[userone@userone OpenShift]$ rhc-ctl-app -a kitchensink -c remove-alias --alias www.myalias.com
Password: ********


RESULT:
Success
..

Stay high on OpenShift !!

Regards,
MiddlewareMagic Team 🙂

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.