Skip to content
Terraform example (create instances using autoscaling and HAproxy as LB)
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

AWS configuration using Terraform

This simple terraform plan will.

  • Create EC2 instance with nginx as reverse proxy 80 -> http://localhost:8080/cgi-bin/
  • Create new AMI using the previous EC2 instance
  • Setup autoscaling for custom AMI created before
  • Download python application from an git repository
  • Setup systemd service to run python application (http.server).
  • Creaate EC2 instance with HAproxy (sticky sessions + stats activated).
  • Add EC2 instances created by the autoscaling to the HAproxy configuration.

EC2 configuration for autoscaling


DOCUMENT_ROOT / => /opt/test
PROXY_REVERSE /cgi-bin =>
GZIP activated
  • Add the required set up to cache the proxied requests for 1 minute.
  • Add headers to responses for static content to be cached by browsers by 1 hour.
  • *Add headers to responses for proxied content to be cached by browsers by 10 minutes.

Python application

ExecStart=/usr/bin/python3 -m http.server --cgi 8080 &
You can’t perform that action at this time.