PHP code example of frdl / proxy

1. Go to this page and download the library: Download frdl/proxy library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

frdl / proxy example snippets



use frdl\Proxy\Proxy;

 
                      $_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);


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);                    
}

$proxy->withCacheDir(string $dir = null, int $ttl= 1800, bool $force=true)