Deploy a NGINX server on private EC2 server and proxy it via REST API

API Gateway → Network Load Balancer → EC2

Create a REST API which acts as a proxy for a NGINX server hosted on a Amazon Elastic Compute Cloud (Amazon EC2)

This sample pattern allows users to quickly deploy a REST API, Network Load Balancer and NGINX server on a EC2 machine in their VPC.
The pattern uses Amazon API Gateway with VPC Link to securely connect to the NLB which routes traffic to EC2 instances running NGINX server.
By using this pattern, users can ensure that their private resources are not exposed to the public internet while still allowing secure access through API Gateway.
This pattern can be useful in scenarios where there is a need to integrate with private resources, such as internal databases or applications, while also maintaining a high level of security.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/apigw-ec2

Deploy

sam deploy --guided


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: sam delete --stack-name

Created by:

Shivam Rajawat

I am a Cloud Support Engineer (Serverless) at AWS and I love to solve complex problems.

Follow on LinkedIn