Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jdavidbakr's avatar

Cloudfront Headers and Symfony 6

So with Laravel 5.6 I'm running into an issue with the TrustProxy middleware. I have my servers behind CloudFront which terminates the SSL, so I need the TrustProxy middleware to recognize the CloudFront proxy as HTTPS. CloudFront, though, uses the header Cloudfront-Forwarded-Proto. In previous versions, I have set the headers like this:

        \Illuminate\Http\Request::HEADER_CLIENT_IP    => 'X_FORWARDED_FOR',
        \Illuminate\Http\Request::HEADER_CLIENT_HOST  => 'X_FORWARDED_HOST',
        \Illuminate\Http\Request::HEADER_CLIENT_PROTO => 'CloudFront-Forwarded-Proto',
        \Illuminate\Http\Request::HEADER_CLIENT_PORT  => 'X_FORWARDED_PORT',

However, Symfony 6 doesn't appear to expose those any more. Does anyone know how I can access the headers? The best solution I have found so far is to configure my apache/nginx to rewrite that header, but I really feel like that's a hack and this should be configurable within Laravel.

0 likes
0 replies

Please or to participate in this conversation.