Deploying Meteor app with free SSL certificate: MUPx, LetsEncrypt, Digital Ocean.

The most recent version of tutorial can be found here: https://github.com/tima101/meteor-deploy-letsencrypt

I recently deployed a multi-core Meteor app with a free SSL certificate but I could not find a good, up-to-date tutorial. So here it is:

Signup for Digital Ocean and deploy Ubuntu droplet. In my case, it was the 2 core ($20/mo) droplet. Open the terminal and login into your account for the first time droplet using your IP address, name (root) and password (emailed to you by Digital Ocean): ssh root@xxx.xxx.xxx.xxx . Set up a new password.

Prepare server (Digital Ocean’s droplet).

Install git on your server (while signed into root@dropletName:~#): apt-get install git

Clone LetsEncrypt: git clone https://github.com/letsencrypt/letsencrypt

Next: cd letsencrypt

Next: ./letsencrypt-auto certonly (-)(-)standalone (-)(-)email xxx@yourdomain.com -d yourdomain.com Remove the parentheses around the dashes! I had to add parentheses since Medium’s editor automatically converts 2 adjacent dashes into one dash. Make sure that your domain has an A record pointing to the right IP address.

Navigate to: etc/letsencrypt/live/yourdomain.com folder. There will be 4 files. Save these 4 files somewhere safe. If you forget the terminal commands for copying a remote file to the local folder, use Filezilla to access your droplet on Digital Ocean (IP address:xxx.xxx.xxx.xxx, username:root, password, port: 22).

You will need the following 2 files: fullchain.pem and privkey.pem . Place these 2 files into your Meteor app’s folder.

Now it’s time to prepare your Meteor app. Install MUPx tool:

Go to the Meteor app folder and run: npm install -g mupx

Then: mupx init This will create a mup.json file in your app’s folder.

Use your droplet’s information and the above 2 pem files to fill out the content of the mup.json file:

“servers”: [
 {
 “host”: “xxx.xxx.xxx.xxx”,
 “username”: “root”,
 “password”: “password”,
 “env”: {}
 }
 ],
 “setupMongo”: false,
 “enableUploadProgressBar”: true,

“appName”: “droplet-name”,

“app”: “/Users/Apps/Desktop/apps/app-folder”,

“env”: {
 “PORT”:80,
 “ROOT_URL”: “https://yourdomain.com",
 “MONGO_URL”: “mongodb://Admin:password@…”
 },

//I use remote https://mlab.com database.

 “ssl”: {
 “certificate”: “./fullchain.pem”, 
 “key”: “./privkey.pem”,
 “port”: 443
 },
 “deployCheckWaitTime”: 30

In your terminal, while inside the app folder, run: mupx setup You will get an error: Installing Docker: FAILED

You gotta go back to your droplet (ssh root@xxx.xxx.xxx.xxx) and install Docker: wget -qO- https://get.docker.com/ | sudo sh

Go back to your local app folder, run again: mupx setup

Then run: meteor add force-ssl (locally your app will be served through http but deployed app will be served through https).

Finally run: mupx deploy

Enjoy!

Optional. Deploy your app on a multi-core droplet.

I deployed my droplet on 2 CPUs ($20/mo, I wish it’s cheaper, gotta learn AWS at some point). So the next few steps will allow my app to actually use those 2 CPUs.

In your local app folder, run again: meteor add meteorhacks:cluster

Then run: export CLUSTER_WORKERS_COUNT=2

Then run: mupx setup and mupx deploy

Hakuna Matata!

Timur, Cofounder of Drizzle