Book Image

Meteor Cookbook

By : Isaac Strack
Book Image

Meteor Cookbook

By: Isaac Strack

Overview of this book

Table of Contents (19 chapters)
Meteor Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Deploying to Meteor using a CNAME redirect


Deploying to Meteor test servers is all well and good, but what if you want to use your own custom domain name? The folks at Meteor have created a simple way for you to do just that. This recipe will show you how to take advantage of this simple, yet powerful feature.

Getting ready

You will need to create a CNAME redirect to origin.meteor.com on the hosting service where your domain is registered. How to do this varies pretty widely, so consult your hosting service's knowledge base on the exact steps. For this recipe, we'll use the cPanel interface of a hosting service for the packtpub.com domain.

Enter the subdomain you wish to use in your CNAME redirect (for example, meteor.packtpub.com) and set the redirect location to origin.meteor.com. Click on Add CNAME Record to submit the record:

How to do it…

Let's assume the subdomain we're going to use is meteor.packtpub.com. In order to deploy to the Meteor environment, perform the following steps:

  1. Once you have your CNAME redirect properly set, open a terminal window, navigate to the root directory of your project, and enter the following:

    $ meteor deploy meteor.packtpub.com
    
  2. Meteor will deploy your app and provide feedback as the bundling, uploading, and serving steps are completed:

    Deploying to meteor.packtpub.com.  Bundling...
    Uploading...
    Now serving at meteor.packtpub.com
    
  3. To verify the application, navigate to your application's URL (for example, http://meteor.packtpub.com) in a browser. If everything was deployed correctly, you will see your application up and running.

How it works…

This Meteor deployment feature is nearly identical to the default deployment, with just a little bit of extra code built in to interpret the origin of CNAME redirect.

When a request comes in to origin.meteor.com via a CNAME redirect, Meteor takes the CNAME redirect's original destination and uses it as the unique identifier for the application deployment. Meteor also uses future requests to origin.meteor.com from this CNAME redirect to serve the application.

In this particular case, the original CNAME destination was meteor.packtpub.com. When the request is redirected to origin.meteor.com, Meteor recognizes the CNAME redirect and uses it to direct traffic to the deployed application.

See also

  • The Deploying a test app to Meteor recipe in this chapter