/ Load Balancing

One Hostname to Rule Them All

One Hostname to rule them all, One Hostname to find them,
One Hostname to bring them all, And in your funnel bind them.

Search-Engine Optimization is vital for a healthy flow of organic traffic to arrive at your pages. How you describe, label, host, secure and organize your pages is directly related to the strength of your search rankings. Within this article, we're going to share with you the mythical, precious SEO power of the One Hostname to Rule Them All.

Enjoy web comics? We have one to match this article! Check it out at OneHostname.com.

The Fellowship of the Things

When you construct an application, your hostname becomes your unique identifier. It is how search engines and users will identify your application; a hostname is the platform upon which you build authority within search engines and recognition from your users.

When crafting your applications, you'll inevitably have a few disparate things that make up one cohesive, branded whole. You might have a...

  • Static marketing site: the face of your enterprise.
  • Robust application: the heart of your enterprise.
  • Blog: the spirit of your enterprise.
  • Docs: the brain of your enterprise.
  • Store: the swagger of your enterprise.

Each of these things will require a unique method of hosting and creation.

Respectively...

  • Static hosting with GitHub Pages or Amazon S3: Jekyll, Hugo, simple HTML.
  • Robust application development through Heroku, Kubernetes, AWS Lambda: there are many methods.
  • Blog hosting through Ghost Blog.
  • Docs through Readme.io.
  • A store through Squarespace.

How will you bind them together? You might think to use a subdomain:

  • onehostname.com for your marketing site; your root domain.
  • app.onehostname.com for your robust application: a subdomain.
  • blog.onehostname.com, docs.subdomain.com and store.onehostname.com... also on subdomains.

With this approach you're, well, DOOMED! Each time you use a subdomain, you are forking the authority from your foundational hostname across separate subdomains. The goal of Search Engine Optimization is to build authority for your hostname. Authority, in brief, is earned through positive user and usage metrics - low bounce rates, return traffic - interlinking by other sources of authority and general visibility. Subdomains accumulate positive signals differently than root domains.

Search engines keep different metrics for domains than they do for subdomains, so even though Google itself has stated that — from a ranking perspective — content in subdomains and subdirectories is treated roughly equally, it's still recommended that webmasters place link-worthy content like blogs in subfolders rather than subdomains (i.e. www.example.com/blog/ rather than blog.example.com).

--Moz SEO Experts, Domain Setup Guide

To build One Hostname, the solution is to use subfolders:

  • onehostname.com/
  • onehostname.com/app
  • onehostname.com/blog/
  • onehostname.com/docs/
  • onehostname.com/store

One Hostname, one subdomain (www): All SEO authority generated into your dear, branded, recognizable hostname. You can read more about subfolders over subdomains here, here, and here.

The Blue Towers

While subfolders are the much wiser option, setting them up is much more complicated. Previously we authored a guide on how you can use Nginx and HAProxy to load balance: GitHub Pages, a self-hosted Ghost Blog and 2x Heroku-hosted Rails applications. The extensive configuration steps revealed a cumbersome route to engineer and balance everything through One Hostname -- all that, and we didn't have HTTPS, had no redundancy or high-availability within our proxies and delivered content from one topographical location.

In order to serve your traffic intelligently upon a single hostname, you'll need to get deep into configuring a reverse proxy. It's a lot of work!

The Return of the Pings

Fly is an Application Delivery Network. When you sign up, you create your site by adding your hostname. Upon this hostname, you can attach all of your backend applications and serve them all over HTTPS through a global network of intelligent load balancers.

Here's what setup looks like...

First, sign up then add your site. You'll need to include your One Hostname then select your backend type. Here, we're starting with humble beginnings: GitHub Pages for our static marketing site. To connect it, we'll need to include our repository name.

Add your one hostname to Fly

Next, we'll be notified of our next steps. All we need to weave your hostname into the Fly global network is to add an ALIAS or CNAME DNS record:

Add a DNS entry to Fly

With the site configured, your GitHub Pages site will now be available from your route domain. Now, we're able to add a variety of backends. We'll choose Heroku, but you can use any type of hosting: Kubernetes, containers, whatever your heart desires.

Adds additional backends to Fly

After we've added a backend, we then create routing rules to determine the subfolder upon which we’d like to mount our application.

Magical Fly routing Rules

Once you've configured routing rules for each backend and tuned your backends to expect their new relative paths, you can marvel at seeing all of your things bound on One Hostname to Rule Them All!

Fly and One Hostname to Rule Them All

Epilogue

We've introduced the One Hostname concept to help you build the mightiest brand that you can. While accomplishing subfolder routing on your own using a reverse proxy is a possibility, you're shackled to on going maintenance, engineering complexity, SSL certificate management, and confined to wherever your infrastructure is hosted. Or, you can use Fly and plug right into a global load balancing network with HTTPS and useful Middleware.

Fly is free to sign up, as are your first 2,000,000 requests and 100GB of transfer.

Kellen Evan Person

@thegoodroot

Kellen Evan Person

A polite, forest-dwelling Canadian who enjoys coding and writing. He's spent near two decades building web applications and strives to keep development fun and light-hearted.

North Vancouver, Canada