PHPackages                             macromindonline/laravel-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. macromindonline/laravel-proxy

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

macromindonline/laravel-proxy
=============================

Set trusted proxies for Laravel

3.3.4(8y ago)014MITPHPPHP &gt;=5.4.0

Since Jul 4Pushed 8y ago1 watchersCompare

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

READMEChangelogDependencies (4)Versions (17)Used By (0)

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

[](#laravel-trusted-proxies)

[![Build Status](https://camo.githubusercontent.com/f152e8cea38fae8aa17fcc61e60f487630d23b487422bc64152d255cee1a22bf/68747470733a2f2f7472617669732d63692e6f72672f666964656c6f7065722f5472757374656450726f78792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/fideloper/TrustedProxy)

[![Total Downloads](https://camo.githubusercontent.com/7638e1a48af64d520209ad1e5b813cf079b4250bf02658aca95e1af95f43ba66/68747470733a2f2f706f7365722e707567782e6f72672f666964656c6f7065722f70726f78792f646f776e6c6f6164732e706e67)](https://packagist.org/packages/fideloper/proxy)

Laravel 5.5
-----------

[](#laravel-55)

**TrustedProxy is now included with Laravel 5.5.** To configure for this version of Laravel, please see:

Laravel 5.0 - 5.4
-----------------

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

For Laravel versions 5.0 - 5.4, please continue below.

New features include:

1. TrustedProxies are now set as in an HTTP Middleware, which makes more logical sense than the previous ServiceProvider. If you're unsure what that means, remember to "Just Trust Fideloper™".
2. You can now set the trusted header names. This is useful for proxies that don't use the usual `X-Forwarded-*` headers. See [issue #9](https://github.com/fideloper/TrustedProxy/issues/9) and [issue #7](https://github.com/fideloper/TrustedProxy/issues/7) for an example and discussion of that.

To use this with Laravel 5, run the following from your Laravel 5 project directory:

```
composer require fideloper/proxy
```

Or of course, you can edit your `composer.json` file directly:

```
{
    "require": {
        "fideloper/proxy": "^3.3"
    }
}
```

Laravel 4
---------

[](#laravel-4)

You can still use this package for Version 4 of Laravel. See the latest v2 tag of this repository, which is compatible with version 4 of Laravel.

WAT
---

[](#wat)

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

This is useful if your web servers sit behind a load balancer, HTTP cache, or other intermediary (reverse) proxy.

TL;DR Setup:
------------

[](#tldr-setup)

Install Trusted Proxy:

```
$ composer require fideloper/proxy
```

Add the Service Provider:

```
'providers' => array(
    # other providers omitted
    'Fideloper\Proxy\TrustedProxyServiceProvider',
);
```

Publish the package config file to `config/trustedproxy.php`:

```
$ php artisan vendor:publish --provider="Fideloper\Proxy\TrustedProxyServiceProvider"
```

Register the HTTP Middleware in file `app/Http/Kernel.php`:

```
    protected $middleware = [
        // Illuminate middlewares omitted for brevity

        'Fideloper\Proxy\TrustProxies',
```

Then edit the published configuration file `config/trustedproxy.php` as needed.

The below will trust a proxy, such as a load balancer or web cache, at IP address `192.168.10.10`:

```
