How to go through downloading from https source to http connection?

I have URLs in the following format (I write it as isgex):

http://exampledomain\.com/files/.+

The URL is requested by the client through my proxy server.

I enter a special authorization header in this request. This is not a problem, I can do it with mod_proxy and mod_headers in apache.

However, this url gives 302 redirection to another source, which finally has to come to the client.

This other URL is SSL protected and looks like this:

https://example.+\.exampledomain.\com/files/.+/.+

He needs the same authorization header as another. But since its hTTPS I can’t just embed it using mod headers.

-, URL- HTTP . script, , URL- HTTPS ( http) .

Apache2 PHP, . .

, rapidshare . , . , , /. , - .

- :

proxy.php - - - - htaccess - revery http://one-or-my-domoains/request-uri-from-the-original-request ( apache)

$url = "http://example.com/".$_SERVER["REQUEST_URI"];
$opts = array(
  'http'=>array(
    'header'=>"Cookie: myauthvalue=example\r\n"
  )
);
$context = stream_context_create($opts);
stream_context_set_default($context);
$http_content = get_headers($url, 1);

$ssl_location = $http_content['Location'];

$fp = fsockopen("ssl://".parse_url($ssl_location, PHP_URL_HOST), 443, $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)<br />\n";
} else {
    $out = "GET ".parse_url($PHP_URL_PATH, PHP_URL_HOST)." HTTP/1.1\r\n";
    $out .= "Host: ".parse_url($ssl_location, PHP_URL_HOST)."\r\n";
    $out .= "Cookie: myauthorization=something"; 
    fwrite($fp, $out);
    while (!feof($fp)) {
        echo fgets($fp, 128);
    }
    fclose($fp);
}

, ssl http-, , .

: ? - ? - ?

, , - .

+3
1

, passthru ('wget....'), ;)

0

All Articles