This demo uses Terraform to set up four instances on AWS and then provides a series of Ansible playbooks to install NGINX Plus, configure an NGINX Plus reverse proxy load balancing between a couple NGINX Plus web servers, and install NGINX App Protect and configure NGINX App Protect to secure the NGINX Plus reverse proxy.
This demo has been developed and tested with Terraform 0.13
.
Instructions on how to install Terraform can be found in the Terraform website.
This demo has been developed and tested with maintained versions of Ansible bigger than 2.9.10
. Backwards compatibility is not guaranteed.
Instructions on how to install Ansible can be found in the Ansible website.
Before running any playbooks you need to deploy the required AWS infrastructure using Terraform.
You can then run the sample playbooks provided to install and configure NGINX Plus and NGINX App Protect.
To use the provided Terraform scripts, you need to:
- Export your AWS credentials as environment variables (or alternatively, tweak the AWS provider in
terraform/provider.tf
). - If you wish to deploy your AWS infrastructure in a different region than the default,
us-west-1
, you will need to tweak theregion
andami
variables present interraform/variables.tf
.
Once you have configured your Terraform environment, you can either:
- Run
./setup.sh
to initialize the AWS Terraform provider and start a Terraform deployment on AWS. - Run
terraform init
andterraform apply
from within theterraform
directory.
And finally, once you are done playing with the Ansible playbooks provided, you can destroy the AWS infrastructure by either:
- Run
./cleanup.sh
to destroy your Terraform deployment. - Run
terraform destroy
from within theterraform directory
.
You can find the playbooks included in the demo in the playbooks/
folder. Playbooks two through four can be deployed in any order, albeit the recommended order gradually configures a more advanced NGINX environment. You will have to deploy playbook one, 1-deploy-nginx.yml
, before you attempt to deploy any other playbooks.
You can also find an AWS inventory plugin playbook in playbooks/aws_ec2.yml
. This plugin will find the instances deployed by Terraform and save them in a temporary inventory list. You can tweak the plugin to your liking with the exception of the filters
and keyed_groups
(these are necessary for the Ansible playbooks to work correctly).
To execute a playbook, run:
ansible-playbook -i playbooks/aws_ec2.yml playbooks/1-deploy-nginx.yml
This demo includes the following playbooks:
Name | Description |
---|---|
0-check-platform.yml |
Check that all platforms have been deployed correctly by Terraform |
1-deploy-nginx.yml |
Deploy NGINX Plus |
2-deploy-nginx-web-server.yml |
Deploy an NGINX Plus web server |
3-deploy-nginx-web-server-proxy.yml |
Deploy an NGINX Plus reverse proxy load balancing between two NGINX Plus web servers |
4-deploy-nginx-app-protect-web-server-proxy.yml |
Deploy an NGINX Plus reverse proxy load balancing between two NGINX Plus web servers protected by NGINX App Protect |
5-check-app-protect.yml |
Check that NGINX App Protect is working as expected |