AWS Cloudfront
VPC
VPN
Cloud Security
Content Delivery Network

Using AWS CloudFront with resources in a VPC or behind a VPN

Codemia Knowledge Hub ·

To put CloudFront in front of resources that live inside a VPC (reached over a VPN), you expose them through a Network Load Balancer, AWS PrivateLink or a proxy, point the CloudFront origin at that endpoint, and use security groups and NACLs so only CloudFront can reach it. CloudFront also supports VPC origins, which let a distribution reach an Application Load Balancer, Network Load Balancer or EC2 instance in a private subnet directly, with no public endpoint.

What CloudFront provides

Amazon CloudFront is a content delivery network (CDN) that delivers data, videos, applications and APIs from edge locations close to users, which reduces latency. Content is served over HTTP or HTTPS. It offers DDoS protection through AWS Shield, encryption at rest, and integration with AWS Web Application Firewall (WAF).

CloudFront usually distributes public content, but sometimes the origin is private: for example, a private web server or an enterprise API hosted in a VPC and connected via a VPN for secure access.

Use cases

  1. Secure enterprise applications: serving enterprise applications that need secure, low-latency access over a VPN.
  2. Private APIs: API gateways integrated with CloudFront share resources securely between on-premises infrastructure and AWS.
  3. Secure content delivery: delivering content securely from a VPC to end users.

Architecture for a private origin

  1. Establish a VPN connection between your on-premises data center and AWS, so the VPC is reachable over a secure network.
  2. Deploy a Network Load Balancer (NLB) to distribute incoming traffic to instances inside the VPC, and configure it so CloudFront can reach it.
  3. Set up PrivateLink or a proxy in the VPC to connect CloudFront to your private resources and keep the connection private.
  4. Configure CloudFront. Create a distribution whose origin settings point to the NLB or the proxy, and enable SSL certificates if you need encrypted connections.
  5. Restrict access with security groups and NACLs so that only CloudFront can reach the resources in your VPC.

Operating the setup

  • Performance: distribute resources correctly with load balancers.
  • Security: use AWS Identity and Access Management (IAM) to control who can change CloudFront configurations.
  • Monitoring: use CloudFront's built-in AWS CloudWatch metrics to monitor network performance and security.

Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design