Proxies for PHP Web App - Noobie Question

maple_toast

Newbie
Joined
Jul 23, 2008
Messages
32
Reaction score
54
I've been searching numerous forums for the answer to this question because it seems like it'd be a common one. However, I think I'm so new I don't know what it is to look for, so I figured I'd just ask:

I'm building a web-application in PHP that will call on remote URLS. Some will be GETs and others POSTs. I want to offer this as a free service, but only if I can build in an anonymous proxy so that my server IP isn't revealed.

Can anyone give me any direction on how to do this?

I've Google'd proxy scripts, and proxy for web-apps, but it seems like all the answers are for client side, not server-side proxies.

Thanks in advance!
 
If you use the curl set of functions to handle your http stuff (which you should, it's the best as far as PHP is concerned) you can easily set proxies using curl_setopt():

curl_setopt($bot, CURLOPT_PROXY, '123.456.789.123:80');

If you need a username and password:

curl_setopt($bot, CURLOPT_PROXYUSERPWD, "$username:$password");

If you have a variety of your own IPs assigned to your box that you want to use, set up Squid proxy server locally and bind your IPs to your instance of Squid, then point your curl/php scripts to your local proxy server. Otherwise you could use external paid or free proxies.
 
Last edited:
Some working code to retrieve your remote page thru proxy 123.123.123.123:8080

Code:
<?  
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, 'http://www.google.com'); 
curl_setopt($ch, CURLOPT_HEADER, 1); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // follow redir
curl_setopt($ch, CURLOPT_PROXY, '123.123.123.123:8080'); // proxy url:port
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'user:password'); // auth
$data = curl_exec(); 
curl_close($ch); 

print $data // do something with the data retrieved
 ?>
 
I use CURL via some ProxyBonanza proxies. Seems to work fine.

-aReJay
 
I use CURL via some ProxyBonanza proxies. Seems to work fine.

-aReJay

I've checked out ProxyBonanza. How does it work? Do they just supply you with a list of ips that you build into your code?
 
If you use the curl set of functions to handle your http stuff (which you should, it's the best as far as PHP is concerned) you can easily set proxies using curl_setopt():

curl_setopt($bot, CURLOPT_PROXY, '123.456.789.123:80');

If you need a username and password:

curl_setopt($bot, CURLOPT_PROXYUSERPWD, "$username:$password");

If you have a variety of your own IPs assigned to your box that you want to use, set up Squid proxy server locally and bind your IPs to your instance of Squid, then point your curl/php scripts to your local proxy server. Otherwise you could use external paid or free proxies.

If you have multiple ips you want to use that are bound to the server you don't need to run squid or any proxy server. curl supports specifying locally bound ips. I'm pretty sure it's via setopt. I'm on my phone right now so you'll have to look it up.
 
Looks like you're right! Very interesting.

curl_setopt($ch, CURLOPT_INTERFACE, "XXX.XXX.XXX.XXX");
 
Back
Top