Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Stuck behind a proxy server |
|
Author |
|
unclepete
Joined: 06 Dec 2007 Posts: 2
|
Posted: Thu 06 Dec '07 11:40 Post subject: Stuck behind a proxy server |
|
|
Hi all - this looks like a very well informed place so I'm hoping you can help!
I've got my Apache server sitting on a windows box and I'm behind a proxy server for internet connections. Not ideal I know, but that's how it is and that's how it's going to stay.
All is beautiful until PHP executes a script that requires fetching information from the internet, at which point it can't retrieve information and hence craps out.
I'm presuming that I need to tell Apache that it needs to use a proxy server to see the wider world, but I'm not sure how to do it.
Initial research suggests that I might need to employ the RemoteProxy directive, but my attempts so far have proven unsuccessful, largely due to the fact that I'm not sure how or where to apply the directive in httpd.conf so I'm pretty much pissing in the wind.
I don't need people outside to see my server, so it really should be straightforward (I desparately hope!). If anyone can shed some light on this for me I'd be mightily grateful, and may even send you a Christmas card! |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Fri 07 Dec '07 2:23 Post subject: |
|
|
Well, Apache doesn't go out and contact anyone, PHP does.
I am surprised that it just won't do it.
If a proxy is setup in your windows network connection for that card, all outbound requests should go through regardless of just what is making said connection, whether it be Apache, PHP, or any other other software making a outbound connection on port 80. You might try this if it is not already done.
I cannot help when it comes to PHP, I viewed that early on as a disaster waiting to happen. So I've never migrated into it really. Hopefully if that meager suggestion doesn't work someone here with good php skills might be able to point something out.
Gregg |
|
Back to top |
|
unclepete
Joined: 06 Dec 2007 Posts: 2
|
Posted: Sat 08 Dec '07 13:05 Post subject: |
|
|
Damn! No wonder I was up the metaphorical creek! Thanks so much for that. At least I'm not being misdirected now. I would never have thought that that was my problem.
Well - if anyone does know how to help me further I'd really appreciate it, but now I'll go try and find me a php guru.
Thanks again. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Sat 08 Dec '07 15:13 Post subject: |
|
|
Which PHP version do you use and which method does your script use to fetch the information from the internet? Some PHP configs may disallow contact the internet.
On the PHP manual page fopen there is a function which can connect through a proxy.
Code: |
<?php
function proxy_url($proxy_url)
{
$proxy_name = '127.0.0.1';
$proxy_port = 4001;
$proxy_user = "user"; // added
$proxy_pass = "password"; // added
$proxy_cont = '';
$proxy_fp = fsockopen($proxy_name, $proxy_port);
if (!$proxy_fp) {return false;}
fputs($proxy_fp, "GET $proxy_url HTTP/1.0\r\nHost: $proxy_name\r\n");
fputs($proxy_fp, "Proxy-Authorization: Basic " . base64_encode ("$proxy_user:$proxy_pass") . "\r\n\r\n"); // added
while(!feof($proxy_fp)) {$proxy_cont .= fread($proxy_fp,4096);}
fclose($proxy_fp);
$proxy_cont = substr($proxy_cont, strpos($proxy_cont,"\r\n\r\n")+4);
return $proxy_cont;
}
?>
|
For debugging you should give out all errors!
So put in the first line of your PHP script
Code: |
error_reporting(E_ALL & ~ E_NOTICE);
|
|
|
Back to top |
|
SFX Group
Joined: 09 Dec 2007 Posts: 3 Location: UK
|
Posted: Sun 09 Dec '07 11:11 Post subject: |
|
|
Hi
Also remember, proxy servers can disallow scripts, your need to check this allow, however i think this is inbount to the client (yout browser) and not outbound once you are working, still something to check.
So best idea is to check that same page at someones home, if it works great, means the proxy is screwing it up, if it doesnt then you know the script doesnt work.
Many Thanks
Ashley |
|
Back to top |
|
|
|
|
|
|