PHPackages                             fmaj/cloudfront-trusted-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. [Caching](/categories/caching)
4. /
5. fmaj/cloudfront-trusted-proxies

ActiveLibrary[Caching](/categories/caching)

fmaj/cloudfront-trusted-proxies
===============================

Provides a way to retrieve cloudfront proxies ip ranges with caching mechanism

1.0.3(6y ago)611.9k2MITPHPPHP &gt;=7.1

Since Feb 5Pushed 6y ago3 watchersCompare

[ Source](https://github.com/florianajir/cloudfront-trusted-proxies)[ Packagist](https://packagist.org/packages/fmaj/cloudfront-trusted-proxies)[ RSS](/packages/fmaj-cloudfront-trusted-proxies/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

cloudfront-trusted-proxies
==========================

[](#cloudfront-trusted-proxies)

[![Build](https://camo.githubusercontent.com/6ca11f3857c31aa643e08b5c84480a67ba67e9045ca3fa39020fc864e82177fa/68747470733a2f2f7472617669732d63692e6f72672f666c6f7269616e616a69722f636c6f756466726f6e742d747275737465642d70726f786965732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/florianajir/cloudfront-trusted-proxies)[![codecov](https://camo.githubusercontent.com/3eb288f6880a90f940786f6b95b82c67d73dd0a64dfd73e74922c0b44624d2af/68747470733a2f2f636f6465636f762e696f2f67682f666c6f7269616e616a69722f636c6f756466726f6e742d747275737465642d70726f786965732f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/florianajir/cloudfront-trusted-proxies)[![Latest Stable Version](https://camo.githubusercontent.com/3b1a179fab26141f3d981bf58f3c001deb7d54d2fd92884d3e5a3f6617518df3/68747470733a2f2f706f7365722e707567782e6f72672f666d616a2f636c6f756466726f6e742d747275737465642d70726f786965732f76657273696f6e)](https://packagist.org/packages/fmaj/cloudfront-trusted-proxies)[![Total Downloads](https://camo.githubusercontent.com/4f771489bc5cf90dbd462a6b6300da2e2027ecaf9ca0a3915192272f3f586d5c/68747470733a2f2f706f7365722e707567782e6f72672f666d616a2f636c6f756466726f6e742d747275737465642d70726f786965732f646f776e6c6f616473)](https://packagist.org/packages/fmaj/cloudfront-trusted-proxies)[![Latest Unstable Version](https://camo.githubusercontent.com/a09ca3f48fb866276f14cb360342e96b429ecb0b2b6b520f155c843b678b8a48/68747470733a2f2f706f7365722e707567782e6f72672f666d616a2f636c6f756466726f6e742d747275737465642d70726f786965732f762f756e737461626c65)](https://packagist.org/packages/fmaj/cloudfront-trusted-proxies)[![License](https://camo.githubusercontent.com/b76bc8cc36145d3094cf58265ebcecbb35e63ae121f11114ae777ec21588e855/68747470733a2f2f706f7365722e707567782e6f72672f666d616a2f636c6f756466726f6e742d747275737465642d70726f786965732f6c6963656e7365)](https://packagist.org/packages/fmaj/cloudfront-trusted-proxies)

Provides a way to retrieve cloudfront proxies ip ranges with caching mechanism

Installation
------------

[](#installation)

`composer require fmaj/cloudfront-trusted-proxies`

Symfony context
---------------

[](#symfony-context)

The initial purpose of this library was to be used in a symfony project, but it's theorically operational in other contexts like a laravel project.

As refered to the [Symfony official documentation](https://symfony.com/doc/current/deployment/proxies.html#but-what-if-the-ip-of-my-reverse-proxy-changes-constantly) , if you are using CloudFront on top of your load balancer symfony does not provide an easy way to trust proxies traffic, as it will only trust the node sitting directly above your application (in this case your load balancer).

That's why you also need to append the IP addresses or ranges of any additional proxy (in this case CloudFront IP ranges) to the array of trusted proxies.

### Usage

[](#usage)

You have to inject a CacheInterface instance to the ProxiesHelper constructor.

In this example a FilesystemAdapter instance (from symfony/cache) is used to store the cloudfront ips for one hour (3600 seconds).

*Note the filesystem cache adapter is often the worst choice for caching performances in production (except on tmpfs storage).*

```
// public/index.php
use Fmaj\CloudfrontTrustedProxies\ProxiesHelper;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\HttpFoundation\Request;

/** @var \Psr\Cache\CacheItemPoolInterface $cachePool */
$cachePool = new FilesystemAdapter('cloudfront_trusted_ips', 3600);
$proxyHelper = new ProxiesHelper($cachePool);
Request::setTrustedProxies(
    $proxyHelper->list(),
    Request::HEADER_X_FORWARDED_AWS_ELB
);
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Every ~44 days

Total

2

Last Release

2250d ago

PHP version history (2 changes)1.0.2PHP ^7.1

1.0.3PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/59b4c5eb6226d578b49ced0976219287e2a07aec91a52038b9093d83a39c6a66?d=identicon)[florianajir](/maintainers/florianajir)

---

Top Contributors

[![florianajir](https://avatars.githubusercontent.com/u/3715903?v=4)](https://github.com/florianajir "florianajir (5 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k348.9M2.5k](/packages/symfony-cache)[symfony/cache-contracts

Generic abstractions related to caching

2.4k308.9M198](/packages/symfony-cache-contracts)[tedivm/stash

The place to keep your cache.

9824.8M124](/packages/tedivm-stash)[league/flysystem-cached-adapter

An adapter decorator to enable meta-data caching.

35426.9M119](/packages/league-flysystem-cached-adapter)[laminas/laminas-cache

Caching implementation with a variety of storage options, as well as codified caching strategies for callbacks, classes, and output

1076.9M130](/packages/laminas-laminas-cache)[cache/adapter-common

Common classes for PSR-6 adapters

11124.4M38](/packages/cache-adapter-common)

PHPackages © 2026

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