PHPackages                             semhoun/proxy-detection-middleware - 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. semhoun/proxy-detection-middleware

Abandoned → [https://github.com/akrabat/proxy-detection-middleware](/?search=https%3A%2F%2Fgithub.com%2Fakrabat%2Fproxy-detection-middleware)ArchivedLibrary

semhoun/proxy-detection-middleware
==================================

PSR-7 Middleware that determines the scheme, host and port from the 'X-Forwarded-Proto', 'X-Forwarded-Host' and 'X-Forwarded-Port' headers and updates the Request's Uri object.

0.5(5y ago)02.2k↓100%BSD-3-ClausePHPPHP ^7.2 || ^8.0

Since Nov 1Pushed 5y agoCompare

[ Source](https://github.com/semhoun/proxy-detection-middleware)[ Packagist](https://packagist.org/packages/semhoun/proxy-detection-middleware)[ Docs](http://github.com/semhoun/proxy-detection-middleware)[ RSS](/packages/semhoun-proxy-detection-middleware/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (9)Versions (9)Used By (0)

Proxy Scheme, Host and Port detection middleware
================================================

[](#proxy-scheme-host-and-port-detection-middleware)

[![Build status](https://camo.githubusercontent.com/71d2fbfcaa356a858a03ee3a84a06a738cf8453ef80f915ff04cfb5773d74ee3/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f73656d686f756e2f726b612d636f6e74656e742d747970652d72656e64657265722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/semhoun/rka-content-type-renderer)

PSR-7 Middleware that determines the scheme, host and port from the 'X-Forwarded-Proto', 'X-Forwarded-Host' and 'X-Forwarded-Port' headers and updates the Request's Uri object.

You can set a list of proxies that are trusted as the second constructor parameter. If this list is set, then the proxy headers will only be checked if the `REMOTE_ADDR` is in the trusted list.

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

[](#installation)

`composer require semhoun/proxy-detection-middleware`

Usage
-----

[](#usage)

In Slim 4:

```
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Server\RequestHandlerInterface as RequestHandler;
use Slim\Factory\AppFactory;
use Slim\Psr7\Response;

require __DIR__ . '/../vendor/autoload.php';

$app = AppFactory::create();

$trustedProxies = ['10.0.0.1', '10.0.0.2', '192.168.0.0/24'];
$app->add(new RKA\Middleware\ProxyDetection($trustedProxies));

$app->get('/', function (Request $request, Response $response, $args) {
    $scheme = $request->getUri()->getScheme();
    $host = $request->getUri()->getHost();
    $port = $request->getUri()->getPort();

    $response->getBody()->write('Real URI is ' . $scheme . '://' . $host . ':' . $port);
    return $response;
});

$app->run();
```

Testing
-------

[](#testing)

- Code coverage: `$ vendor/bin/phpcs`
- Unit tests: `$ vendor/bin/phpunit`

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity63

Established project with proven stability

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 ~471 days

Total

5

Last Release

1955d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/efb83f2b876f8b6122c07c99af97df13bf208ba264d77b7b08dc1a1e30365e20?d=identicon)[semhoun](/maintainers/semhoun)

---

Tags

middlewarepsr7IP

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/semhoun-proxy-detection-middleware/health.svg)

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

###  Alternatives

[akrabat/ip-address-middleware

PSR-15 middleware that determines the client IP address and stores it as a ServerRequest attribute

1702.5M18](/packages/akrabat-ip-address-middleware)[cakephp/authentication

Authentication plugin for CakePHP

1153.6M67](/packages/cakephp-authentication)[akrabat/proxy-detection-middleware

PSR-7/PSR-15 Middleware that determines the scheme, host and port from the 'X-Forwarded-Proto', 'X-Forwarded-Host' and 'X-Forwarded-Port' headers and updates the Request's Uri object.

3190.4k1](/packages/akrabat-proxy-detection-middleware)[mezzio/mezzio-authentication-oauth2

OAuth2 (server) authentication middleware for Mezzio and PSR-7 applications.

28483.0k2](/packages/mezzio-mezzio-authentication-oauth2)[mezzio/mezzio-authentication

Authentication middleware for Mezzio and PSR-7 applications

121.6M26](/packages/mezzio-mezzio-authentication)[yiisoft/yii-middleware

Yii Middleware

21151.3k1](/packages/yiisoft-yii-middleware)

PHPackages © 2026

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