PHPackages                             fideloper/proxy - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. fideloper/proxy

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

fideloper/proxy
===============

Set trusted proxies for Laravel

4.4.2(4y ago)7.3k174.4M—6.8%129[1 issues](https://github.com/fideloper/TrustedProxy/issues)[5 PRs](https://github.com/fideloper/TrustedProxy/pulls)20MITPHPPHP &gt;=5.4.0

Since Jul 4Pushed 2y ago25 watchersCompare

[ Source](https://github.com/fideloper/TrustedProxy)[ Packagist](https://packagist.org/packages/fideloper/proxy)[ RSS](/packages/fideloper-proxy/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (27)Used By (20)

Laravel Trusted Proxies
=======================

[](#laravel-trusted-proxies)

[![Build Status](https://github.com/fideloper/TrustedProxy/workflows/Tests/badge.svg)](https://github.com/fideloper/TrustedProxy/actions) [![Total Downloads](https://camo.githubusercontent.com/7638e1a48af64d520209ad1e5b813cf079b4250bf02658aca95e1af95f43ba66/68747470733a2f2f706f7365722e707567782e6f72672f666964656c6f7065722f70726f78792f646f776e6c6f6164732e706e67)](https://packagist.org/packages/fideloper/proxy)

**Setting a trusted proxy allows for correct URL generation, redirecting, session handling and logging in Laravel when behind a reverse proxy such as a load balancer or cache.**

---

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

[](#installation)

**Laravel 5.5+ comes with this package**. If you are using Laravel 5.5 or greater, you **do not** need to add this to your project separately.

- [Laravel 5.5](https://laravel.com/docs/5.5/requests#configuring-trusted-proxies) Docs (`fideloper/proxy:~3.3`)
- [Laravel 5.6](https://laravel.com/docs/5.6/requests#configuring-trusted-proxies) Docs (`fideloper/proxy:^4.0`)
- [Laravel 5.7](https://laravel.com/docs/5.7/requests#configuring-trusted-proxies) Docs (`fideloper/proxy:^4.0`)
- [Laravel 5.8](https://laravel.com/docs/5.8/requests#configuring-trusted-proxies) Docs (`fideloper/proxy:^4.0`)
- [Laravel 6.x](https://laravel.com/docs/6.x/requests#configuring-trusted-proxies) Docs (`fideloper/proxy:^4.0`)
- [Laravel 7.x](https://laravel.com/docs/7.x/requests#configuring-trusted-proxies) Docs (`fideloper/proxy:^4.2`)
- [Laravel 8.x](https://laravel.com/docs/8.x/requests#configuring-trusted-proxies) Docs (`fideloper/proxy:^4.3`)
- [Laravel 9.x](https://laravel.com/docs/9.x/requests#configuring-trusted-proxies) Docs (**Don't use this package**. [Explanation here](https://github.com/fideloper/TrustedProxy/issues/152), [Upgrade docs here](https://laravel.com/docs/9.x/upgrade))

### Laravel 5.0 - 5.4

[](#laravel-50---54)

To install Trusted Proxy, use:

```
composer require fideloper/proxy:^3.3

```

### Laravel 4

[](#laravel-4)

```
composer require fideloper/proxy:^2.0

```

Setup
-----

[](#setup)

Refer to the docs above for using Trusted Proxy in Laravel 5.5+. For Laravel 4.0 - 5.4, refer to [the wiki](https://github.com/fideloper/TrustedProxy/wiki).

What Does This Do?
------------------

[](#what-does-this-do)

Setting a trusted proxy allows for correct URL generation, redirecting, session handling and logging in Laravel when behind a reverse proxy.

This is useful if your web servers sit behind a load balancer (Nginx, HAProxy, Envoy, ELB/ALB, etc), HTTP cache (CloudFlare, Squid, Varnish, etc), or other intermediary (reverse) proxy.

How Does This Work?
-------------------

[](#how-does-this-work)

Applications behind a reverse proxy typically read some HTTP headers such as `X-Forwarded`, `X-Forwarded-For`, `X-Forwarded-Proto` (and more) to know about the real end-client making an HTTP request.

> If those headers were not set, then the application code would think every incoming HTTP request would be from the proxy.

Laravel (technically the Symfony HTTP base classes) have a concept of a "trusted proxy", where those `X-Forwarded` headers will only be used if the source IP address of the request is known. In other words, it only trusts those headers if the proxy is trusted.

This package creates an easier interface to that option. You can set the IP addresses of the proxies (that the application would see, so it may be a private network IP address), and the Symfony HTTP classes will know to use the `X-Forwarded` headers if an HTTP requets containing those headers was from the trusted proxy.

Why Does This Matter?
---------------------

[](#why-does-this-matter)

A very common load balancing approach is to send `https://` requests to a load balancer, but send `http://` requests to the application servers behind the load balancer.

For example, you may send a request in your browser to `https://example.org`. The load balancer, in turn, might send requests to an application server at `http://192.168.1.23`.

What if that server returns a redirect, or generates an asset url? The users's browser would get back a redirect or HTML that includes `http://192.168.1.23` in it, which is clearly wrong.

What happens is that the application thinks its hostname is `192.168.1.23` and the schema is `http://`. It doesn't know that the end client used `https://example.org` for its web request.

So the application needs to know to read the `X-Forwarded` headers to get the correct request details (schema `https://`, host `example.org`).

Laravel/Symfony automatically reads those headers, but only if the trusted proxy configuration is set to "trust" the load balancer/reverse proxy.

> Note: Many of us use hosted load balancers/proxies such as AWS ELB/ALB, etc. We don't know the IP address of those reverse proxies, and so you need to trusted **all** proxies in that case.
>
> The trade-off there is running the security risk of allowing people to potentially spoof the `X-Forwarded` headers.

IP Addresses by Service
-----------------------

[](#ip-addresses-by-service)

[This Wiki page](https://github.com/fideloper/TrustedProxy/wiki/IP-Addresses-of-Popular-Services) has a list of popular services and their IP addresses of their servers, if available. Any updates or suggestions are welcome!

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity82

Widely adopted with strong download metrics

Community54

Growing community involvement

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 64.9% 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 ~142 days

Recently: every ~195 days

Total

23

Last Release

1559d ago

Major Versions

1.0.0 → 2.0.12013-12-12

2.1.1 → 3.0.02015-02-04

3.3.4 → 4.0.02018-02-07

PHP version history (2 changes)1.0.0PHP &gt;=5.3.0

3.0.0PHP &gt;=5.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5ffe7f19bdf080aaa14107239624d682f2e1b139b9459e93b56966649a4d7873?d=identicon)[fideloper](/maintainers/fideloper)

---

Top Contributors

[![fideloper](https://avatars.githubusercontent.com/u/467411?v=4)](https://github.com/fideloper "fideloper (146 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (34 commits)")[![vluzrmos](https://avatars.githubusercontent.com/u/450848?v=4)](https://github.com/vluzrmos "vluzrmos (5 commits)")[![rrpadilla](https://avatars.githubusercontent.com/u/6921286?v=4)](https://github.com/rrpadilla "rrpadilla (5 commits)")[![Keoghan](https://avatars.githubusercontent.com/u/6714599?v=4)](https://github.com/Keoghan "Keoghan (4 commits)")[![taylorotwell](https://avatars.githubusercontent.com/u/463230?v=4)](https://github.com/taylorotwell "taylorotwell (4 commits)")[![ssfinney](https://avatars.githubusercontent.com/u/1596394?v=4)](https://github.com/ssfinney "ssfinney (3 commits)")[![JohnnyWalkerDigital](https://avatars.githubusercontent.com/u/6763222?v=4)](https://github.com/JohnnyWalkerDigital "JohnnyWalkerDigital (3 commits)")[![tamc](https://avatars.githubusercontent.com/u/43987?v=4)](https://github.com/tamc "tamc (3 commits)")[![Bradez](https://avatars.githubusercontent.com/u/919214?v=4)](https://github.com/Bradez "Bradez (2 commits)")[![djallits](https://avatars.githubusercontent.com/u/10674226?v=4)](https://github.com/djallits "djallits (2 commits)")[![anaxamaxan](https://avatars.githubusercontent.com/u/439457?v=4)](https://github.com/anaxamaxan "anaxamaxan (1 commits)")[![lucasff](https://avatars.githubusercontent.com/u/4260591?v=4)](https://github.com/lucasff "lucasff (1 commits)")[![nicoqh](https://avatars.githubusercontent.com/u/3981388?v=4)](https://github.com/nicoqh "nicoqh (1 commits)")[![dwightwatson](https://avatars.githubusercontent.com/u/1100408?v=4)](https://github.com/dwightwatson "dwightwatson (1 commits)")[![rodruiz](https://avatars.githubusercontent.com/u/10534494?v=4)](https://github.com/rodruiz "rodruiz (1 commits)")[![samnela](https://avatars.githubusercontent.com/u/1852108?v=4)](https://github.com/samnela "samnela (1 commits)")[![SerafimArts](https://avatars.githubusercontent.com/u/2461257?v=4)](https://github.com/SerafimArts "SerafimArts (1 commits)")[![StevenBullen](https://avatars.githubusercontent.com/u/239862?v=4)](https://github.com/StevenBullen "StevenBullen (1 commits)")[![barryvdh](https://avatars.githubusercontent.com/u/973269?v=4)](https://github.com/barryvdh "barryvdh (1 commits)")

---

Tags

proxytrusted proxyload balancing

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fideloper-proxy/health.svg)

```
[![Health](https://phpackages.com/badges/fideloper-proxy/health.svg)](https://phpackages.com/packages/fideloper-proxy)
```

###  Alternatives

[ocramius/proxy-manager

A library providing utilities to generate, instantiate and generally operate with Object Proxies

5.0k82.4M230](/packages/ocramius-proxy-manager)[symfony/var-exporter

Provides tools to export, instantiate, hydrate, clone and lazy-load PHP objects

2.1k378.1M441](/packages/symfony-var-exporter)[friendsofphp/proxy-manager-lts

Adding support for a wider range of PHP versions to ocramius/proxy-manager

1.2k139.1M104](/packages/friendsofphp-proxy-manager-lts)[vkartaviy/retry

The library for repeatable and retryable operations

29227.2k2](/packages/vkartaviy-retry)[astrotomic/php-conditional-proxy

This package provides a trait and class to allow calling methods based on a condition without breaking the method chain.

30155.8k5](/packages/astrotomic-php-conditional-proxy)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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