1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Proxies for PHP Web App - Noobie Question

Discussion in 'Proxies' started by maple_toast, Apr 14, 2011.

  1. maple_toast

    maple_toast Newbie

    Joined:
    Jul 23, 2008
    Messages:
    30
    Likes Received:
    50
    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!
     
  2. Autumn

    Autumn Elite Member

    Joined:
    Nov 18, 2010
    Messages:
    2,197
    Likes Received:
    3,041
    Occupation:
    I figure out ways to make money online and then au
    Location:
    Spamville
    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.
     
    • Thanks Thanks x 1
    Last edited: Apr 14, 2011
  3. sirgold

    sirgold Supreme Member

    Joined:
    Jun 25, 2010
    Messages:
    1,260
    Likes Received:
    645
    Occupation:
    Busy proving the Pareto principle right
    Location:
    A hot one
    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
     ?>
    
     
    • Thanks Thanks x 1
  4. aReJay

    aReJay Power Member

    Joined:
    Apr 29, 2009
    Messages:
    736
    Likes Received:
    237
    Location:
    Down under
    I use CURL via some ProxyBonanza proxies. Seems to work fine.

    -aReJay
     
  5. maple_toast

    maple_toast Newbie

    Joined:
    Jul 23, 2008
    Messages:
    30
    Likes Received:
    50
    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?
     
  6. The Doctor

    The Doctor Jr. VIP Jr. VIP

    Joined:
    Dec 18, 2010
    Messages:
    612
    Likes Received:
    188
    Occupation:
    Computer Scientist, Engineer, Programmer.
    Location:
    ☆☆☆☆☆☆
    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.
     
    • Thanks Thanks x 2
  7. Autumn

    Autumn Elite Member

    Joined:
    Nov 18, 2010
    Messages:
    2,197
    Likes Received:
    3,041
    Occupation:
    I figure out ways to make money online and then au
    Location:
    Spamville
    Looks like you're right! Very interesting.

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