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

## Overview

<figure><img src="/files/adaWs8Ao6M6C9Ae7WkGp" alt=""><figcaption></figcaption></figure>

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.                                                                                                                                                                                                             &#x20;

&#x20;What you'll build:                                                                                                        &#x20;

&#x20;• Complete AWS infrastructure (VPC, subnet, security groups, EC2 instance)

&#x20;• DNS configuration via Route 53

&#x20;• Caddy web server with automatic HTTPS

&#x20;• Static website accessible via custom subdomain

&#x20;• Production ready setup with HTTP to HTTPS redirect

all in less than 10 min

## How Stakpak Helps?

You don't need to know anything about networking, or AWS or Caddy to sit it up, you dont need to go through documentation or Google commands

## Step by Step Guide

### Prerequisites

1. [Install Stakpak](/docs/get-started/install-stakpak.md)
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

<figure><img src="/files/jxiU2y64cMwdwM6GURAV" alt=""><figcaption></figcaption></figure>

6. it will create&#x20;
   1. Internet Gateway
   2. &#x20;Attach Internet Gateway to VPC
   3. &#x20;Create a public subnet
   4. Create a route table with an internet route
   5. Create security group (ports 22, 80, 443)
   6. Generate SSH key pair
7. Now it will create the EC2 instance&#x20;
8. Now we drink coffee while the EC2 instance starts
9. Now it will set the DNS and install Caddy, and test it

   <figure><img src="/files/nf6aCAueKXkTntWAN8cB" alt=""><figcaption></figcaption></figure>

## Now it's working🥳

<figure><img src="/files/4jWgVFHjonKNsNrdkOrt" alt=""><figcaption></figcaption></figure>

## Extra Resources:

### References

* [Install Stakpak](/docs/get-started/install-stakpak.md)
* [EC2 Documentation](https://docs.aws.amazon.com/ec2/)
* [VPC Documentation](mailto:undefined)
* [Route 53 Documentation](https://docs.aws.amazon.com/route53/)
* [Caddy Documentation](https://caddyserver.com/docs/)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://stakpak.gitbook.io/docs/tutorial/free-tls-with-caddy-web-server-on-aws-ec2-with-lets-encrypt.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
