PHPackages                             autumndev/cloudfront-proxies - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. autumndev/cloudfront-proxies

ActiveLibrary[HTTP &amp; Networking](/categories/http)

autumndev/cloudfront-proxies
============================

Sets proxy settings for Cloudfront in a Laravel project

v1.0(3y ago)065MITPHP

Since May 10Pushed 3y agoCompare

[ Source](https://github.com/scott-davidjones/CloudfrontProxies)[ Packagist](https://packagist.org/packages/autumndev/cloudfront-proxies)[ RSS](/packages/autumndev-cloudfront-proxies/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

Cloudfront Proxies
==================

[](#cloudfront-proxies)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c07167d3408d8ab0b73787f750d735f0c48e7a87fd804f6ec53e1f32a215e146/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a646176696462616b722f636c6f756466726f6e742d70726f786965732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jdavidbakr/cloudfront-proxies)[![Total Downloads](https://camo.githubusercontent.com/4e96d8a5998b8681bec55f8ac926d03cfb4df345b2363bd0d2b61166fdddf73c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a646176696462616b722f636c6f756466726f6e742d70726f786965732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jdavidbakr/cloudfront-proxies)[![Travis](https://camo.githubusercontent.com/ac6d7a6dc8607076288205f152f57ef27e1f0d028d670f0fd5293dc96afc373e/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6a646176696462616b722f636c6f756466726f6e7470726f786965732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/jdavidbakr/cloudfrontproxies)

Purpose
-------

[](#purpose)

One of the great things about putting your application behind a load balancer or CDN is that you can terminate your TLS there, and make the requests to your application via http. The problem with this, though, is that your application is not aware of the protocol with which it is being accessed. This will cause a problem with Laravel's URL generation tools, as the assets will be prefixed with http.

Laravel takes care of this nicely by using the TrustedProxies package, which allows you to define what IP addresses and what headers you want to use to convert the incoming request to the IP address and protocol of the originating request.

This was all wonderful, until Laravel 5.6 came out. This version of Laravel uses Symfony version 4, which no longer exposes the header you want to use to determine the protocol. Not a problem, you say, because you can use the X-Forwarded headers? It wouldn't be a problem, except for the fact that CloudFront uses a special header `Cloudfront-Forwarded-Proto` - and so now there is not a simple solution to set the protocol.

Further, you probably don't want to expose all IP addresses to your trusted proxy settings - ideally we should only use CloudFront IP addresses for our trusted proxies.

The solution
------------

[](#the-solution)

This package contains a simple middleware that does two very important tasks:

1. Downloads the CloudFront IP addresses into the trusted proxy IP addresses. This is cached according to your cache settings for one hour, so you are not making this call on every request.
2. Adds the `X-Forwarded-Proto` header to your requests based on the `Cloudfront-Forwarded-Proto` value. This helps Symfony behave as if the original headers were what it needed in the first place.

This middleware only fires if the `Cloudfront-Forwarded-Proto` header exists in the incoming headers, so it is ignored if you are using other load balancers or accessing the server directly. Note that CloudFront does not send this header by default - it must be explicitly whitelisted. (See the CloudFront documentation for more information on sending headers and cookies)

Usage
-----

[](#usage)

To use, simply install via composer:

```
composer require jdavidbakr/cloudfront-proxies

```

Then add the middleware to your kernel after the `TrustProxies` middleware:

```
        \App\Http\Middleware\TrustProxies::class,
        \jdavidbakr\CloudfrontProxies\CloudfrontProxies::class,

```

If you desire, you may publish the config file to give you access to some options:

```
php artisan vendor:publish

```

This will publish a `cloudfront-proxies.php` config file that you may edit.

And everything should be good to go from here.

###  Health Score

22

—

LowBetter than 23% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1095d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2fdae8757045573e236136afb10fc9cdfef8aade0c6c04e0a49a07aca6347164?d=identicon)[autumndev](/maintainers/autumndev)

---

Top Contributors

[![scott-davidjones](https://avatars.githubusercontent.com/u/547193?v=4)](https://github.com/scott-davidjones "scott-davidjones (5 commits)")[![jdavidbakr](https://avatars.githubusercontent.com/u/25177?v=4)](https://github.com/jdavidbakr "jdavidbakr (4 commits)")[![josiasmontag](https://avatars.githubusercontent.com/u/1945577?v=4)](https://github.com/josiasmontag "josiasmontag (1 commits)")

---

Tags

laravelcloudfronttrusted proxies

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/autumndev-cloudfront-proxies/health.svg)

```
[![Health](https://phpackages.com/badges/autumndev-cloudfront-proxies/health.svg)](https://phpackages.com/packages/autumndev-cloudfront-proxies)
```

###  Alternatives

[omniphx/forrest

A Laravel library for Salesforce

2724.4M8](/packages/omniphx-forrest)[muhammadhuzaifa/telescope-guzzle-watcher

Telescope Guzzle Watcher provide a custom watcher for intercepting http requests made via guzzlehttp/guzzle php library. The package uses the on\_stats request option for extracting the request/response data. The watcher intercept and log the request into the Laravel Telescope HTTP Client Watcher.

98239.8k1](/packages/muhammadhuzaifa-telescope-guzzle-watcher)[jdavidbakr/cloudfront-proxies

Sets proxy settings for Cloudfront in a Laravel project

23274.4k](/packages/jdavidbakr-cloudfront-proxies)[api-platform/laravel

API Platform support for Laravel

59126.4k5](/packages/api-platform-laravel)[meema/laravel-cloudfront

Easily &amp; quickly integrate your application with AWS CloudFront.

31113.4k](/packages/meema-laravel-cloudfront)[laravel-shift/curl-converter

A command line tool to convert curl requests to Laravel HTTP requests.

935.3k](/packages/laravel-shift-curl-converter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
