Form.io/AWS Elastic Beanstalk End-To-End Encrypted Deployment
This tutorial will walk through how to create an example Form.io deployment environment on AWS Elastic Beanstalk that enables TLS/SSL-encrypted communication to the load balancer, from the load balancer to the EC2 instances, and lastly between each container within each instance. This tutorial assumes you have prior knowledge of Form.io and AWS Elastic Beanstalk, that you have an already running Form.io deployment in Elastic Beanstalk, and that your Elastic Beanstalk load balancer has an attached HTTPS listener. Please see AWS Deployment for more details.
"This deployment setup is seldom required and is intended for advanced Form.io configurations, particularly for customers with stringent external security requirements. If you're unsure whether your deployment needs TLS/SSL-encrypted communication between containers, please reach out to support@form.io.
Load Balancer Configuration
First, we'll need to ensure that the HTTPS listener on our load balancer will re-encrypt traffic going to the instances by adding an environment configuration file. Please see the Elastic Beanstalk documentation for more details.
.ebextensions/https-reencrypt-alb.config
Second, we'll need to modify our load balancer's security group to allow traffic. This will depend on whether you adopted a default security group or created a custom one during your Elastic Beanstalk environment creation; to cover both scenarios, use the following configuration file to create a security group and attach it to the load balancer.
.ebextensions/https-lbsecuritygroup.config
Be sure to replace ########
with your vpc identification number
Next, we'll add ingress and egress rules that allow communication over port 443 between the load balancer's security group and the instances' security group.
.ebextensions/https-backendsecurity.config
Now that we've ensured TLS/SSL-encrypted traffic from the load balancer to our instances, we'll move on to configuring our instances to be able to handle HTTPS traffic.
Instance Configuration
In a typical enterprise deployment of the Form.io platform, each server instance behind the load balancer will contain the Enterprise Server Docker container, the PDF Server Docker container, and a reverse proxy (commonly nginx running in its own Docker container) to direct traffic that arrives at the instance to one or both services.
docker-compose.yml
Since our load balancer will be sending HTTPS traffic, we'll first need to ensure that our nginx reverse proxy can process HTTPS traffic by updating our conf.d
file.
conf.d/default.conf
You can find more details about this reverse proxy configuration in our deployment guide, but generally, this reverse proxy will be able to receive HTTPS traffic and direct it, encrypted, to our containers at HTTPS addresses (in this case provided by the Docker network, e.g. https://api-server:3000
or https://pdf-server:4005
).
Now that our instances can receive HTTPS traffic and direct it to our containers, the final step will be to configure our Form.io applications to be able to receive this traffic.
Container/NodeJS Configuration
Since the Form.io Enterprise Server and the Form.io PDF Server are NodeJS applications, we'll need to configure them to be able to process TLS/SSL-encrypted traffic. For this, we'll add the SSL_ENABLED, SSL_KEY, and SSL_CERT variables to each environment configuration (you of course can accomplish this via an environment file or via the Elastic Beanstalk configuration console).
.env
Pay special attention to these variables, as they should contain the content of the key and the certificate and not their path in the filesystem. Additionally, they should be a single line escaped with \n
characters.
Keep in mind that NodeJS maintains its own trusted root certificate store. If you're using certificates with a private CA (or using a tool like mkcert) you'll need to add your root certificate to NodeJS by using the NODE_EXTRA_CA_CERTS
environment variable (e.g. NODE_EXTRA_CA_CERTS=/src/certs/rootCA.pem
). We don't recommend self-signed certificates for this configuration.
With these variables in your environment, NodeJS will be able to accept TLS/SSL-encrypted traffic, and your deployment is encrypted end-to-end!
Last updated