How to access EC2 over HTTPS? [No ACM, No LB]

Mohammad Moallemi
2 min readAug 25, 2021
How to access EC2 over HTTPS? [No ACM, No LB]

Motivation / Why?

There are times that you just need to spin up a server quickly, experiment with something and etc… but you need an HTTPS secure connection. (e.g. WebRTC signaling calls, webhook requests)

Overview

In this article, we’re gonna use AWS API Gateway proxy in order to have an HTTPS connection for our API deployed on an EC2 instance.
There are some articles and tutorials out there which use a load balancer (ALB/NLB), VPC Link to achieve this same goal, but they would cost you extra money which we can easily avoid.

Steps / How?

0. I assume you have an API deployed on an EC2 instance ready at xa.yb.zc.dd IP.
1. Log in to the AWS console and go to the API gateway service.
2. Click Create API
3. Choose HTTP API and click Build.
4. In the first step of creating an API Gateway, you need to add two integrations:
1. HTTP | ANY | http://xa.yb.zc.dd
2. HTTP | ANY | http://xa.yb.zc.dd/{path}

Creating API Gateway with HTTP Integration
Creating API Gateway with HTTP Integration

The first one is for matching this route http://xa.yb.zc.dd without any trailing slash and the second one is for a catch-all/wildcard behavior.

5. In the second step enter these values to map API gateway routes to integrations:
1. $default | http://xa.yb.zc.dd
2. ANY | /{path+} | http://xa.yb.zc.dd/{path}

Mapping API gateway routes to HTTP integrations
Mapping API gateway routes to HTTP integrations

6. Configure stages and create the API gateway

Yay!
Now you have an HTTPS proxy ready for your EC2 instance, hope this was helpful to you.
Please leave a comment if you had any challenges, issues setting this up, or a better solution to achieve this goal.

Originally published at https://mmoallemi99.com on August 25, 2021.

--

--