AWS integration
import { Render, APIRequest } from "~/components";
This guide will walk you through how to set up per-hostname authenticated origin pulls to securely connect to an AWS Application Load Balancer using mutual TLS verify.
Before you begin
- You should already have your AWS account and EC2 configured.
- Note that this tutorial uses command-line interface (CLI) to generate a custom certificate, and API calls to configure Cloudflare Authenticated Origin Pulls.
- For the most up-to-date documentation on how to set up AWS, refer to the AWS documentation.
1. Generate a custom certificate
2. Configure AWS Application Load Balancer
- Upload the
rootca.certto an S3 bucket. - Create a trust store at your EC2 console, indicating the S3 URI where you uploaded the certificate.
- Create an EC2 instance and install an HTTPD daemon. Choose an instance type according to your needs - it can be a minimal instance eligible to AWS Free Tier. This tutorial was based on an example using t2.micro and Amazon Linux 2023.
sudo yum install -y httpd
sudo systemctl start httpd
- Create a target group for your Application Load Balancer.
- Choose Instances as target type.
- Specify port
HTTP/80.
- After you finish configuring the target group, confirm that the target group is healthy.
- Configure a load balancer and a listener.
- Choose the Internet-facing scheme.
- Switch the listener to port
443so that the mTLS option is available, and select the target group created in previous steps. - For Default SSL/TLS server certificate, choose Import certificate > Import to ACM, and add the certificate private key and body.
- Under Client certificate handling, select Verify with trust store.
- Save your settings.
- (Optional) Run the following commands to confirm that the Application Load Balancing is asking for the client certificate.
openssl s_client -verify 5 -connect <your-application-load-balancer>:443 -quiet -state
Since you have not yet uploaded the certificate to Cloudflare, the connection should fail (read:errno=54, for example).
You can also run curl --verbose and confirm Request CERT (13) is present within the SSL/TLS handshake:
curl --verbose https://<your-application-load-balancer>
...
* TLSv1.2 (IN), TLS handshake, Request CERT (13):
...
3. Configure Cloudflare
- Upload the certificate you created in Step 1 to Cloudflare. You should use the leaf certificate, not the root CA.
- Associate the certificate with the hostname that should use it.
<APIRequest path="/zones/{zone_id}/origin_tls_client_auth/hostnames" method="PUT" json={{ config: [ { enabled: true, cert_id: "<CERT_ID>", hostname: "<YOUR_HOSTNAME>", }, ], }} />
:::note
Make sure your encryption mode is set to Full or higher. If you only want to adjust this setting for a specific hostname, use Configuration Rules. :::
Roll back the Cloudflare configuration
谢谢你的反馈!