Wikipedia para siempre
TreeWeb::Artículos::PHP::Proxy inverso
Permalink: http://www.treeweb.es/u/1283/ 01/02/2015

Proxy inverso

Es un proxy inverso, inicialmente pensado para bypassear la protección CORS del navegador y facilitar así en algunos casos el desarrollo de aplicaciones JavaScript.

Otro uso muy interesante es proteger 
<?php $protocol = 'http'; $host = 'es.wikipedia.org'; $request = $_SERVER['REQUEST_URI']; $url = $protocol.'://'.$host.$request; if (!file_exists('cache/'.md5($url))) { $postdata = http_build_query($_POST); $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata ) ); $opts = array('http' => array( 'method' => 'GET', 'header' => 'Content-type: application/x-www-form-urlencoded'."\r\n" .'User-Agent: Mozilla/5.0 (Ubuntu; X11; Linux x86_64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1', 'content' => $postdata ) ); $context = stream_context_create($opts); $data = file_get_contents($url, false, $context); if ($_SERVER['REQUEST_URI'] == '/robots.txt') $data = ''; unset($http_response_header[8]); $headers = true; $headers = var_export($http_response_header, true); $string = "<?php \$headers = ".$headers."; foreach (\$headers as \$h) header(str_replace('es.wikipedia.org',\$_SERVER['SERVER_NAME'],\$h)); ?> ".str_replace('<meta name="robots" content="noindex,nofollow" />','',$data); file_put_contents('cache/'.md5($url),$string); // Cabeceras que me envía el navegador $http = array(); foreach ($_SERVER as $S=>$s) { if (strpos($S,'HTTP_') === 0) { $http[$S] = $s; } } } include('cache/'.md5($url)); ?>