PHP Classes

PHP Proxy Server Script: Forward HTTP requests to other servers as a proxy

Recommend this page to a friend!
  Info   View files Documentation   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 75 All time: 10,163 This week: 673Up
Version License PHP version Categories
proxy 1.0MIT/X Consortium ...5Networking, HTTP, PHP 5
Description 

Author

This package can be used to forward HTTP requests to other servers as a proxy.

It can work as a proxy server that can be configured to handle HTTP requests from Web browsers or other types of programs to forward the requests to destination HTTP servers.

The package can also forward requests to specific remote Web servers with URLs passed manually to the proxy server class.

Picture of Till Wehowski
  Performance   Level  
Name: Till Wehowski <contact>
Classes: 30 packages by
Country: Germany Germany
Age: 45
All time rank: 107269 in Germany Germany
Week rank: 321 Up11 in Germany Germany Up
Innovation award
Innovation award
Nominee: 12x

Documentation

frdl/proxy

Simple Php Proxy based on Guzzle.

Installation

Use Composer...

composer require frdl/proxy

...or the Webfan Installer if you would like to build a larger project.

Usage

<?php
use frdl\Proxy\Proxy;

 require 'vendor/autoload.php'; 
 
 	$proxy = (new Proxy(null,
                      $_SERVER['REQUEST_URI'],
                      'green.example.com',  //target host
                      $_SERVER['HTTP_HOST'],  //User Input, forward optionaly*
                      $_SERVER['REQUEST_METHOD'], 
                      'https', 
                      false))
        ->withFakeHost(true) //*Do overwrite/not use users host header
        //...or...
        ->withFakeHeader('X-Forwarded-Host')
    ;
    
	$proxy->handle(true);

Internally the proxy ignores the bounce-detection silently to fallback to any localhost scripts. You can use it before/without handling the HTTP-Forwarding, e.g. to perform a (test-)request on the same host.

<?php
if(!$proxy->bounce()){	
 	$proxy = (new Proxy('blue',
                      $_SERVER['REQUEST_URI'],
                      'blue.example.com',  //target host
                      'example.com',  //set the host header on the target script
                      $_SERVER['REQUEST_METHOD'], 
                      'https', 
                      true))
  ->handle(true);                    
}


  Files folder image Files  
File Role Description
Files folder imagesrc (4 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files  /  src  
File Role Description
  Accessible without login Plain text file ClientProxy.php Class Class source
  Accessible without login Plain text file PatchAutoloadFunctions.php Class Class source
  Accessible without login Plain text file Proxy.php Class Class source
  Accessible without login Plain text file Response.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:75
This week:0
All time:10,163
This week:673Up