Setting Up TLS(SSL) On A VPS With LetsEncrypt

Anosike Osifo
Tilte
Published in
2 min readNov 25, 2018

I needed to setup HTTPS on a web app running on an AWS EC2 instance. I almost got lost in the rabbit-hole of moving from solving one error to another; thankfully, I had a thought to go with a relatively obvious solution — only to discover that setting up HTTPS was a really easy thing to do!

My Application Setup

I had a lightweight micro-service based setup:

  • Two(2) NodeJS services running on local ports.
  • An API Gateway running on a subdomain (it also proxies requests to the other services).
  • A web-client running on another subdomain.

I considered these SSL Certificate Authorities(CA) Options:

ACM

The Setup process for ACM was pretty straight-forward, and as described on the website, however, after getting it validated, I had trouble figuring out how to get it to work with my Nginx configurations — until i stumbled on this:

TL;DR:

Q: Can I use certificates on Amazon EC2 instances or on my own servers?

A: No. At this time, certificates provided by ACM can only be used with specific AWS services.

See full Stack Overflow question here.

LetsEncrypt

Following the Getting Started Guide was seamless, at least until I got to the Certbot Guide for my setup.

I already had my nginx setup for multiple subdomain, thus i thought a wildcard certificate would be appropriate. For a while i was lost here:

I tried using the Certbot DNS plugin for AWS Route53, which was my DNS provider, and after a number of failed attempts, i went with the preceding, instruction:

$ sudo certbot --nginx

Once i ran this command, Certbot proved its awesomeness and guided me through the process of setting up HTTPS for the various subdomains i had in my Nginx configuration.

Thats it, the above command did it!

Setting up SSL for multiple subdomains on a VPS (EC2) was that easy!

I hope this helps someone save some time, and cut out some frustration. :)

Kindly let me know your thoughts!

--

--