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    
Last Updated Ratings Unique User Downloads Download Rankings
2021-02-02 (11 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 57 All time: 10,072 This week: 174Up
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: 27 packages by
Country: Germany Germany
Innovation award
Innovation award
Nominee: 9x

Details

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:57
This week:0
All time:10,072
This week:174Up
For more information send a message to info at phpclasses dot org.