Code Monkey home page Code Monkey logo

fargate-reverse-proxy-with-static-ips's Introduction

Nginx Proxy

This module deploys an Nginx reverse proxy in an ECS Fargate cluster.

Architecture

The goal is to provide a static IP address to external clients, and have that static IP go to some resource inside the AWS environment. We will terminate SSL on the proxy in case the internal resource does not support SSL. The classic use case is providing an SSL endpoint for a static web site hosted in an S3 bucket, where we can't use CloudFront because we need a static IP rather than a DNS endpoint.

Customize

You can customize the Nginx configuration by editing docker/nginx.conf. We use the placeholder PROXY_FOR in the location directive; we'll substitute your desired target URL at run time. You can use any other Nginx configuration you like in this file.

Create a file called local.tfvars. You must provide values for:

  • region: The AWS region you want to deploy in
  • NginxImage: You will fill this in after you build the Docker image.
  • ProxyFor: Set this to a URL that Nginx will relay traffic to, for example https://www.amazon.com.
  • ingress_cidr: Set this to a CIDR range for allowed ingress to the NLB.

You can also override any of the defaults in variables.tf.

Build the Nginx image

Build the image with a self-signed cert:

cd docker
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout cert.key -out cert.crt
build_and_push.sh nginx-proxy

You can use a cert from a valid CA instead if you have one available.

Note the value of the Nginx image in ECR, and put this into local.tfvars as the NginxImage parameter.

Deploy Terraform

Deploy Terraform:

cd ..
tf init
tf apply -var-file="local.tfvars"

You'll get the load balancer endpoint as the output of the stack.

License

See the LICENSE file in this repo.

fargate-reverse-proxy-with-static-ips's People

Contributors

amazon-auto avatar rddefauw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.