地址:http-dyn.abuyun.com,端口:9020
HTTP隧道拥有两种授权模式:
通过用户名/密码的形式进行身份认证,该认证信息最终会转换为『Proxy-Authorization』协议头跟随请求一起发出。
为便于部分语言进行接入,平台亦支持通过『Authorization』协议头进行隧道身份验证。
只须绑定用户发起请求的服务器IP即可。
一条代理隧道只能绑定一个IP,同一IP可以分别绑定到专业版、动态版、经典版代理隧道各一条。
const http = require("http");
const url = require("url");
// 要访问的目标页面
const targetUrl = "http://test.abuyun.com";
const urlParsed = url.parse(targetUrl);
// 代理服务器
const proxyHost = "http-dyn.abuyun.com";
const proxyPort = "9020";
// 代理隧道验证信息
const proxyUser = "H01234567890123D";
const proxyPass = "0123456789012345";
const base64 = new Buffer(proxyUser + ":" + proxyPass).toString("base64");
const options = {
host : proxyHost,
port : proxyPort,
path : targetUrl,
method : "GET",
headers : {
"Host" : urlParsed.hostname,
"Proxy-Authorization" : "Basic " + base64
}
};
http
.request(options, function(res) {
console.log("got response: " + res.statusCode);
})
.on("error", function(err) {
console.log(err);
})
.end()
;
const request = require("request");
// 要访问的目标页面
const targetUrl = "http://test.abuyun.com";
// 代理服务器
const proxyHost = "http-dyn.abuyun.com";
const proxyPort = 9020;
// 代理隧道验证信息
const proxyUser = "H01234567890123D";
const proxyPass = "0123456789012345";
const proxyUrl = "http://" + proxyUser + ":" + proxyPass + "@" + proxyHost + ":" + proxyPort;
const proxiedRequest = request.defaults({'proxy': proxyUrl});
const options = {
url : targetUrl,
headers : {
}
};
proxiedRequest
.get(options, function (err, res, body) {
console.log("got response: " + res.statusCode);
})
.on("error", function (err) {
console.log(err);
})
;
const request = require("superagent");
require("superagent-proxy")(request);
// 要访问的目标页面
const targetUrl = "http://test.abuyun.com";
// 代理服务器
const proxyHost = "http-dyn.abuyun.com";
const proxyPort = 9020;
// 代理隧道验证信息
const proxyUser = "H01234567890123D";
const proxyPass = "0123456789012345";
const proxyUrl = "http://" + proxyUser + ":" + proxyPass + "@" + proxyHost + ":" + proxyPort;
request
.get(targetUrl)
.proxy(proxyUrl)
.end(function onResponse(err, res) {
if (err) {
return console.log(err);
}
console.log(res.status, res.headers);
console.log(res.text);
})
;
// 请安装 puppeteer v1.12.2 (详见 https://github.com/GoogleChrome/puppeteer/issues/4143)
const puppeteer = require("puppeteer");
// 代理服务器
const proxyHost = "http-dyn.abuyun.com";
const proxyPort = 9020;
const proxyServer = "http://" + proxyHost + ":" + proxyPort;
// 隧道验证信息
const proxyUser = "H01234567890123D";
const proxyPass = "0123456789012345";
(async () => {
const browser = await puppeteer.launch({
ignoreHTTPSErrors: true,
headless: false,
args: ["--proxy-server=" + proxyServer]
});
const page = await browser.newPage();
await page.authenticate({ username : proxyUser, password : proxyPass});
try {
await page.goto("https://test.abuyun.com", {timeout: 3000});
}
catch(err) {
console.log(err);
}
})();
const axios = require('axios');
// 要访问的目标页面
var targetUrl = "http://test.abuyun.com";
// 代理服务器
const proxyHost = "http-dyn.abuyun.com";
const proxyPort = 9020;
// 代理隧道验证信息
const proxyUser = "H01234567890123D";
const proxyPass = "0123456789012345";
var proxy = {
host: proxyHost,
port: proxyPort,
auth: {
username: proxyUser,
password: proxyPass
}
};
// 参见官方文档 https://github.com/axios/axios#request-config
axios.get(targetUrl,{proxy:proxy})
.then(function (response) {
// handle success
console.log(response.data);
})
.catch(function (error) {
// handle error
console.log(error);
})
.finally(function () {
// always executed
});