Serving a S3 Bucket with Kubernetes and Ingress-Nginx

The traditional, production-ready way to serve a S3 bucket in production is usually to create a CloudFront distribution, add a S3 origin and configure the desired behaviour. However, this comes with a small caveat: while you can specify an origin path, this will make CloudFront request the bucket from the path directory, then appending the requested URL. For example, given the test origin path, example.com/index.html will retrieve s3://bucket-name/test/index.html; example.com/folder/index.html will retrieve s3://bucket-name/test/folder/index.html. In other words, the folder structure must match the URL structure, which is not always the desired outcome. While one could use CloudFront Lambda@Edge to overcome this, if CloudFront is not necessary to begin with there is a simpler solution with Kubernetes and ingress-nginx. ...

March 3, 2024 · 2 min · Adrien Poupa