I am attempting to script the retrieval of an secure (password protected + https) URL trough a proxy server that requires authentication. I found many examples of how to use the ‘proxy’ option and how to send credentials with stream_context_create.
$url = "https://$server/$uri";
$cred = sprintf('Authorization: Basic %s\r\n', base64_encode("$user:$pass"));
$options['header']=$cred;
$options['proxy']="tcp://10.1.1.1:3128";
$params = array('http' => $options);
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
However I did not find any where a uid/password was provided to the proxy server. I attempted to add a header manually:
$prox_cred = sprintf('Proxy-Connection: Keep-Alive\r\nProxy-Authorization: Basic %s\r\n', base64_encode("$proxy_user:$proxy_pass"));
$options['header'] .= $prox_cred;
I have root access to the proxy server and I can see my request hitting it, but when I look into the traffic I don’t see my headers. I guess they are being added to the portion that gets encrypted and sent to the end server.
For some reason I didn’t want to complicate things by using the cURL modules for the first time. However based on the responses I tried it and it took about 6 minutes to get things working.
Thanks!