DEV Community

Cover image for Free TLS with Caddy Web Server on AWS EC2 with Let's Encrypt
Noureldin ehab for AWS Community Builders

Posted on • Originally published at stakpak.gitbook.io

Free TLS with Caddy Web Server on AWS EC2 with Let's Encrypt

Overview

In this tutorial, we will see how to deploy a static website on AWS EC2 using Caddy web server with automatic HTTPS certificates from Let's Encrypt.

What you'll build:

  • Complete AWS infrastructure (VPC, subnet, security groups, EC2 instance)

  • DNS configuration via Route 53

  • Caddy web server with automatic HTTPS

  • Static website accessible via custom subdomain

  • Production ready setup with HTTP to HTTPS redirect

all in less than 10 min

Note: Stakpak is open source, vendor neutral, and works with any model you choose.

Step by Step Guide

Prerequisites

  1. Install Stakpak

  2. Open your terminal and type "stakpak"

  3. Cloud provider credentials configured

Turorial

  1. Then ask Stakpak to install caddy on Ubuntu on EC2

  2. It will start by checking the AWS creds and region

  1. It will create:
  • Internet Gateway
  • Attach Internet Gateway to VPC
  • Create a public subnet
  • Create a route table with an internet route
  • Create security group (ports 22, 80, 443)
  • Generate SSH key pair
  1. Now it will create the EC2 instance

  2. Now we drink coffee while the EC2 instance starts

  3. Now it will set the DNS and install Caddy, and test it

Now it's working🥳

Extra Resources:

References

Top comments (0)