Saturday, July 7, 2012

How-To: Setting Up Multiple Custom Domains for a GAE Application

Google's platform-as-a-service (PaaS), Google App Engine, can be a great solution for web applications that require massive scaling (or the potential thereof) and the scaling needing to be largely transparent for both developers and end-users. With its free usage tier, App Engine also serves as a great platform for proof-of-concepts and "live" testing grounds. It currently has a fairly robust list of services and support to accommodate most web application needs and they are on a fairly aggressive release schedule fixing and adding features on a regular basis.

In spite of all the work they, App Engine, have put into making the development and deployment of web applications easy, they have somewhat forgotten about one of the most important aspects of the whole process: custom domain setup. Not to say they have completely neglected the issue, but they have delegated all domain setup to Google Apps. This coupling means that you can't setup a custom domain for your app, unless you have that domain somehow "registered" with Google Apps. This also makes the workflow to add a custom domain to your app rather cumbersome requiring having a Google Apps account, singing in, adding, verifying, etc. What if you wanted to assign more than one domain name to your app? Well, the only documentation I could find was for adding a custom domain to an app, but it doesn't really explain the process or the requirements. So, to solve this problem I pretty much tried every trick in the book (and documentation) to no avail. After trying some clever permutations of steps and work-arounds, I was able to set up two custom domains for the same app and only one Google Apps account. Be advised that this work-around won't solve the problem of custom SSL certificates for your domains, for more info in this topic subscribe to their Google Groups group (google-appengine) which is usually brimming with Q&A's regarding SSL for applications. Below are the steps necessary to add multiple custom domains to the same application.

What you need:
  • An active App Engine application
  • You must be an "owner" of the App Engine app.
  • A Google Apps account (even if it's for a different domain) and you must have a domain admin or super admin role.
  • Access to your domain's DNS settings.
Steps:
Interestingly enough, the simplest way to add custom domains to an App Engine app is to not deal with App Engine at all. All the steps below are accomplished from within Google Apps (and your domain registrar), not App Engine.

  1. Log into your Google Apps control panel
  2. Click on Domain Settings
  3. Click on Domain Names sub tab
  4. Click on Add a domain or domain alias
  5. (Assuming the Google Apps domain is not the one you want associated with your GAE app) select Add a domain alias of [domain.name]
  6. Enter the domain alias in the text input below it
  7. Click on Continue and verify domain ownership
  8. After you verify ownership of the domain and the domain alias has been successfully added, click on Settings on the top navigation bar of the Google Apps control panel.
  9. On the left-hand vertical bar, click on the GAE application you want to associate the domains to (usually they are labeled as: <appname (App Engine)>)
  10. In the Web address section, click on Add new URL
  11. A text box and a dropdown menu will show up prefaced by a "http://" enter the subdomain (i.e. www or such). This implies you cannot setup naked (i.e. http://domain.name) domains for App Engine apps, at least not directly.
  12. Finally select the domain name from the dropdown menu and click on Add 
  13. Setup your domain's CNAME records as instructed.
You can repeat this process to add as many custom domain names to your GAE application as you wish. Now, as said above, you cannot add naked domains to your GAE apps; however, there's a trick you can use to accomplish the same effect. The specific steps change from registrar to registrar and also bear in mind that some DNS services take anywhere from a few minutes to a few hours for changes to be applied, but in essence you'd want to:
  1. Point your www.domain.name DNS to the CNAME that Google Apps provided you
  2. Set URL-Forwarding on the naked domain to forward requests to www.domain.name
Assuming everything went as expected, you should now be able to reach your App Engine app at both http://www.domain.name and http://domain.name.

I'll close by saying that most of the steps and work-arounds above would not be necessary if App Engine had its own domain/dns management service and here's to hoping they'll add such service to App Engine soon.

No comments:

Post a Comment