使用工具测试代理服务接口的步骤及示例。
使用 /__proxy__/ 接口设置目标 Host:
# 使用 curl 设置 Host 为 https://httpbin.org
curl "http://你的代理服务器地址/__proxy__/?host=https://httpbin.org"
# 响应(成功设置)
{ "host": "https://httpbin.org", "status": true }
设置 Host 后,通过根路径转发请求:
# 转发 GET 请求到 https://httpbin.org/get?test=123
curl "http://你的代理服务器地址/get?test=123"
# 响应(与 https://httpbin.org/get?test=123 一致)
{
"args": { "test": "123" },
"headers": { ... },
"origin": "代理服务器IP",
"url": "https://httpbin.org/get?test=123"
}
测试 Base64 编码参数的 POST 请求转发:
# 1. 构建原始 JSON
{ "url": "https://httpbin.org/post", "method": "POST", "body": { "proxy": "test" } }
# 2. 转换为 Base64(结果)
eyJ1cmwiOiJodHRwczovL2h0dHBiaW4ub3JnL3Bvc3QiLCJtZXRob2QiOiJQT1NUIiwiYm9keSI6eyJwcm94eSI6InRlc3QifX0=
# 3. URL 编码后发起请求
curl "http://你的代理服务器地址/__proxy__/fetch?arg=eyJ1cmwiOiJodHRwczovL2h0dHBiaW4ub3JnL3Bvc3QiLCJtZXRob2QiOiJQT1NUIiwiYm9keSI6eyJwcm94eSI6InRlc3QifX0%3D"
# 响应(与 https://httpbin.org/post 接收的内容一致)
{
"args": {},
"data": "{\"proxy\":\"test\"}",
"json": { "proxy": "test" },
...
}
不设置 Host,直接通过 ?url= 参数转发:
# 直接转发到指定 URL
curl "http://你的代理服务器地址/__proxy__/?url=https://httpbin.org/headers"
# 响应(返回目标 URL 的内容)
{ "headers": { ... } }
检查响应中的 origin 字段(应为代理服务器 IP),或通过 httpbin.org/ip 确认:
# 验证代理 IP
curl "http://你的代理服务器地址/__proxy__/?url=https://httpbin.org/ip"
# 响应(origin 为代理服务器 IP)
{ "origin": "代理服务器IP" }