HTTP隧道 (经典版)
PHP 接入指南

隧道验证方式

地址:http-cla.abuyun.com,端口:9030

隧道验证方式

HTTP隧道拥有两种授权模式:

  • 请求头(默认)

通过用户名/密码的形式进行身份认证,该认证信息最终会转换为『Proxy-Authorization』协议头跟随请求一起发出。

为便于部分语言进行接入,平台亦支持通过『Authorization』协议头进行隧道身份验证。

  • 绑定IP(暂未启用)

只须绑定用户发起请求的服务器IP即可。

一条代理隧道只能绑定一个IP,同一IP可以分别绑定到专业版、动态版、经典版代理隧道各一条。

              
    // 要访问的目标页面
    $targetUrl = "http://test.abuyun.com";
    //$targetUrl = "http://proxy.abuyun.com/switch-ip";
    //$targetUrl = "http://proxy.abuyun.com/current-ip";

    // 代理服务器
    $proxyServer = "http://http-cla.abuyun.com:9030";

    // 隧道身份信息
    $proxyUser   = "H01234567890123C";
    $proxyPass   = "0123456789012345";

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $targetUrl);

    curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    // 设置代理服务器
    curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
    curl_setopt($ch, CURLOPT_PROXY, $proxyServer);

    // 设置隧道验证信息
    curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_PROXYUSERPWD, "{$proxyUser}:{$proxyPass}");

    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727;)");

    //curl_setopt($ch, CURLOPT_HTTPHEADER, [
    //    "Proxy-Switch-Ip: yes",
    //]);

    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);

    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $result = curl_exec($ch);
    //$info = curl_getinfo($ch);

    curl_close($ch);

    var_dump($result);              
            
              
    // 要访问的目标页面
    $targetUrl = "http://test.abuyun.com";
    //$targetUrl = "http://proxy.abuyun.com/switch-ip";
    //$targetUrl = "http://proxy.abuyun.com/current-ip";

    // 代理服务器
    $proxyServer = "http-cla.abuyun.com:9030";

    // 隧道身份信息
    $proxyUser   = "H01234567890123C";
    $proxyPass   = "0123456789012345";

    $proxyAuth = base64_encode("{$proxyUser}:{$proxyPass}");

    $headers = implode("\r\n", [
        "Proxy-Authorization: Basic {$proxyAuth}",
        "Proxy-Switch-Ip: yes",
    ]);

    $options = [
        "http" => [
            "proxy"  => $proxyServer,
            "header" => $headers,
            "method" => "GET",
        ],
    ];

    $context = stream_context_create($options);

    $result = file_get_contents($url, false, $context);

    var_dump($result);              
            
体验服务
现在开始,体验阿布云大数据服务
计算、网络、大数据、人工智能,阿布云助您飞跃发展