How to securely expose your local app to the internet using EC2?

Ali Haydar
5 min readJan 31

Are you developing an app and want others to access it before it’s available in the cloud? Or are you integrating with a third-party tool and wish to enable access to your local app for a better development experience? This article is for you.

There are many use cases where you might need to expose your local app (the app you are developing on your local machine) to the internet. That could be a site, an API or a chatbot. I’ve worked on a few of these cases, most recently a side project developing a Slack application.

When integrating with Slack, you need to provide Slack with a redirection URL so that the user goes back to your site after granting the necessary permissions (this is common when using [OAuth](

As you are working on a local machine, the URL should point to your localhost, which has a private IP. Your home/office router will have a public IP assigned by the internet provider, but any device behind that router will be given a private IP. So how can we expose our app to the internet?

How to expose your app to the internet?

Note that this setup might incur some costs.

First, I used ngrok, which creates a tunnel between my local machine and servers that are already exposed to the internet — So your requests to the ngrok server get forwarded to your local app. That’s convenient and useful. However, the URL of that server changes every time you connect, which means I need to update my app config every time I connect.

I wanted something more permanent and maintainable, where I start my app, add my changes and test. One option was to subscribe to the ngrok paid services, where you can get a permanent URL. I need this for a side project and want it to be cost-effective, so I decided to implement a basic solution myself.

To achieve this, we’ll create an EC2 instance that allows ingress access from the internet, and install an nginx server that acts as a reverse proxy to forward requests to this server to my app running on my local machine, using SSH tunnelling.

Let’s build it with Terraform.

Ali Haydar

Software engineer (JS | REACT | Node | AWS | Test Automation)