Laravel 5.6 and CloudFront

jdavidbakr posted 1 year ago

So, I'm upgrading to Laravel 5.6 and am running into a problem with the new Symfony settings for trusted proxies. Since the new interface doesn't expose the headers, does anyone know how I tell it to use Cloudfront-Forwarded-Proto instead of the X-Forwarded-Proto header? The only thing I've found is to add a header translation in the Apache or Nginx config files, but I really want to contain this logic within my app and not rely on that. Any thoughts?

jdavidbakr replied 11 months ago

If anyone else has this issue, I have released a middleware package that I am hoping will solve it. I've tested it locally but don't yet have a production-ready system to test it -actually- behind cloudfront, so if anyone does use it in a live environment before I do I'd love to get feedback. The package both pulls in the CloudFront IP's as well as rewrites the Cloudfront-Forwarded-Proto header to X-Forwarded-Proto, but only if Cloudfront-Forwarded-Proto header exists.

Sign in to participate in this thread!

We'd like to thank these amazing companies for supporting us