URL 参数代理脚本


URL Parameter Proxy Script

有没有办法通过URL参数设置代理?该脚本应该在 Ubuntu 服务器上运行。或者是否有可能用鱿鱼或类似的东西来完成?

喜欢http://proxyserver.com:3128/http://google.de

我已经尝试了一些PHP代理脚本,但它并没有真正使用它。它应该将文件作为流打开,但使用某些脚本加载整个文件,然后我得到输出,或者它不适用于 Safari,并且在每个浏览器上我都遇到了 javascript 的错误来获取流的信息。

可能这有帮助,为什么它不适用于野生动物园。我不知道如何进一步编辑标题。设置接受范围等

另一个编辑

在此处尝试此代码。发布已实现。

$url = $_GET["url"];
$method = $_SERVER["REQUEST_METHOD"];
$data = array($_POST);
$options = array(
  "http" => array(
    "header"  => "Content-type: application/x-www-form-urlencoded'r'n",
    "method"  => $method,
    "content" => http_build_query($data),
  ),
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$filter = "/(http|https|ftp|ftps)(:'/'/)/i";
$result = preg_replace($filter, "http://YOURDOMAIN.com/FOLDER/LOCATIONOFTHEPROXY.php?url=$1$2", $result);
echo $result;
var_dump($result);

编辑

在这里,我找到了一些使用 phP 进行 POST 的代码。现在才要实施它。

<?php
$url = "url to post to;
$data = array("comment" => "Testing PhP Post", "name" => "A PhP Script");
// use key "http" even if you send the request to https://...
$options = array(
  "http" => array(
    "header"  => "Content-type: application/x-www-form-urlencoded'r'n",
    "method"  => "POST",
    "content" => http_build_query($data),
  ),
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }
echo $result;
var_dump($result);
?>

你试过file_get_contents()吗?

试试这个:

<?php
  echo file_get_contents($_GET["url"]);
?>

使用查询调用文件,如 ?url=http://google.com/

如果你想用一个php代理开始,你应该使用Glype代理

此外,您的网址http://proxyserver.com:3128/http://google.de无效,被视为格式错误的网址。

要修复它,您必须转义其他URL(带有查询刺痛左右)。 例如 $URL_in_PHP = "http://proxyserver.com:3128/?url=".urlencode('http://google.de');

var URL_in_javascript = "http://proxyserver.com:3128/?url="+encodeURI('http://google.de');

并告知代理服务器导航到$_GET['url']

我解决了。

我使用了带有proxy_pass参数的nginx服务器