2017 © Pedro Peláez
 

library rka-scheme-and-host-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.

image

akrabat/rka-scheme-and-host-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.

  • Sunday, November 13, 2016
  • by akrabat
  • Repository
  • 3 Watchers
  • 24 Stars
  • 10,977 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 1 Open issues
  • 4 Versions
  • 14 % Grown

The README.md

Proxy Scheme, Host and Port detection middleware

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., (*1)

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., (*2)

Installation

composer require akrabat/proxy-detection-middleware, (*3)

Usage

In Slim 3:, (*4)

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

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

    return $response;
});

Testing

  • Code coverage: $ vendor/bin/phpcs
  • Unit tests: $ vendor/bin/phpunit
  • Code coverage: $ vendor/bin/phpunit --coverage-html ./build

The Versions

13/11 2016

dev-master

9999999-dev http://github.com/akrabat/rka-scheme-and-host-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.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr7 ip

13/11 2016

0.3

0.3.0.0 http://github.com/akrabat/rka-scheme-and-host-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.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr7 ip

21/04 2016

0.2

0.2.0.0 http://github.com/akrabat/rka-scheme-and-host-detection-middleware

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

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr7 ip

01/11 2015

0.1

0.1.0.0 http://github.com/akrabat/rka-scheme-and-host-detection-middleware

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

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr7 ip