Download the PHP package jakubboucek/nette-http-request-strict-proxy without Composer

On this page you can find all versions of the php package jakubboucek/nette-http-request-strict-proxy. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package nette-http-request-strict-proxy

Nette HTTP Request Strict Proxy

Strict trusted proxy verification for Nette HTTP: the connecting peer (your CDN / reverse proxy) is trusted only when the request carries a valid pre-shared key (PSK) header — never based on its IP address alone.

The problem

When your app runs behind a CDN (Cloudflare, Fastly, …), Nette needs to know the CDN's IP addresses (http › proxy configuration) to read the real client IP from the X-Forwarded-For header. That brings two problems:

The solution

Configure your CDN to add a secret header to every request it forwards to your origin server (e.g. a Cloudflare Request Header Transform Rule). The header value is a static PSK — a shared secret between the CDN and the origin.

This package hooks into the http.request service creation:

  1. If the incoming request carries the PSK header with a valid key, the connecting peer's IP is passed to Nette\Http\RequestFactory::setProxy() as a trusted proxy — whatever its IP address is. The forwarded client IP is then resolved by standard Nette logic.
  2. If the header is missing or invalid, nothing is trusted dynamically (fail-closed) and the request behaves as a direct connection.

Highlights:

Installation

Requires PHP 8.1+ and Nette HTTP 3.2+.

Configuration

Register the extension and set the key(s):

All options:

With an empty pskKeys list nothing is ever trusted — the extension is fail-closed.

Generate a strong key, e.g.:

CDN setup (Cloudflare example)

Create a Request Header Transform Rule (Rules → Transform Rules → Modify Request Header):

Cloudflare then adds the header to every request forwarded to your origin. Anyone hitting the origin directly doesn't know the key and cannot forge it.

Defense in depth: block direct access at the web server

This package makes proxy-header spoofing harmless, but you may want to reject direct (non-CDN) requests entirely before they reach PHP. On Apache:

Key rotation

  1. Add a new key to pskKeys (keep the old one) and deploy.
  2. Change the header value in the CDN rule to the new key.
  3. Remove the old key from pskKeys and deploy.

No downtime, no window with an untrusted CDN.

Security notes

Standalone usage (without Nette DI)

Tests

License

MIT. See the LICENSE file.


All versions of nette-http-request-strict-proxy with dependencies

PHP Build Version
Package Version
Requires php Version ~8.1
nette/di Version ^3.2
nette/http Version ^3.2
nette/schema Version ^1.2
nette/utils Version ^3.2 || ^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jakubboucek/nette-http-request-strict-proxy contains the following files

Loading the files please wait ...