Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a proxy using a php script?

Tags:

http

php

curl

proxy

Let's say i got a vps hosting with a dedicated ip, can i make a curl php script that receives a url, fetch it, and output it, and make all this as a proxy server, so i can put my vps ip in the proxy settings of the browser.

Is there any way to do that?

Note: Please don't suggest me a web based proxy like glype.

Thanks

like image 746
CodeOverload Avatar asked Aug 26 '10 23:08

CodeOverload


3 Answers

Yes, you could (see Jasper's answer). That would be effectively making your own web-based proxy.

However, given that it's a VPS, I would suggest using a SSH SOCKS proxy, since it'll be easier and will be running through an encrypted tunnel to the VPS.

like image 151
zebediah49 Avatar answered Oct 15 '22 19:10

zebediah49


Use Apache with mod_proxy and mod_proxy_http. See the docs.

You can access the proxy through https, effectively encrypting all your traffic between your computer and the VPS.

like image 1
Artefacto Avatar answered Oct 15 '22 18:10

Artefacto


You can use tor proxy, here is the script:

<?php
function tor_new_identity($tor_ip='127.0.0.1', $control_port='9051',$auth_code='saad'){
$fp = fsockopen($tor_ip, $control_port, $errno, $errstr, 30);
if (!$fp) return false; //can't connect to the control port

fputs($fp, "AUTHENTICATE $auth_code\r\n");
$response = fread($fp, 1024);
list($code, $text) = explode(' ', $response, 2);
if ($code != '250') return false; //authentication failed

//send the request to for new identity
fputs($fp, "signal NEWNYM\r\n");
$response = fread($fp, 1024);
list($code, $text) = explode(' ', $response, 2);
if ($code != '250') return false; //signal failed

fclose($fp);
return true;
}

?>

Call the function "if (tor_new_identity('127.0.0.01', '9051')) {//do stuffs here}" But you must install the tor system in the VPS 1st.

like image 1
Gunner_aziz Avatar answered Oct 15 '22 19:10

Gunner_aziz