Nginx behind Cloudfront

Self-hosting services on EC2 instances can come with unexpected behavior. If the service is hosted using Nginx, it typically expects a "Host" header. If you have Cloudfront between the EC2 instance and the internet (e.g., for caching, delivery, etc.), Cloudfront won't forward the "Host" header by default.

In Cloudfront settings, go to "Behavior."

Select "Use legacy cache settings"

Select "Whitelist" as the method to whitelist Headers

Select "Host" then click "Add >>"

Wait for Cloudfront to deplay and you should be good!

Additional resource:

Configure CloudFront to forward the Host header to the origin
Cloudfront Nginx Rewrite Causing Problems
I am setting up a cdn using cloudfront. My origin for my cloudfront distribution is my aws load balancer (ELB). When I make a request to cloudfront instead of getting the cloudfront url (cdn.mysite...