Примеры

Hosts ru.proksusha.ru / de.proksusha.ru — плейсхолдеры. Язык выбирается один раз для всей страницы.

1. Fetch через chain ru→de

export KEY=pk_live_...
export RU=https://ru.proksusha.ru

curl -L \
  -H "X-Api-Key: $KEY" \
  -H "X-Chain: ru->de" \
  "$RU/v1/fetch?url=https://example.com/releases/app.zip" \
  -o app.zip
import httpx

KEY = "pk_live_..."
RU = "https://ru.proksusha.ru"
url = f"{RU}/v1/fetch"
params = {"url": "https://example.com/releases/app.zip"}
headers = {"X-Api-Key": KEY, "X-Chain": "ru->de"}

with httpx.stream("GET", url, params=params, headers=headers, follow_redirects=True) as r:
    r.raise_for_status()
    with open("app.zip", "wb") as f:
        for chunk in r.iter_bytes():
            f.write(chunk)
import { writeFile } from "node:fs/promises";

const KEY = "pk_live_...";
const RU = "https://ru.proksusha.ru";
const target = encodeURIComponent("https://example.com/releases/app.zip");

const res = await fetch(`${RU}/v1/fetch?url=${target}`, {
  headers: { "X-Api-Key": KEY, "X-Chain": "ru->de" },
  redirect: "follow",
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
await writeFile("app.zip", Buffer.from(await res.arrayBuffer()));
package main

import (
	"io"
	"net/http"
	"net/url"
	"os"
)

func main() {
	key := "pk_live_..."
	ru := "https://ru.proksusha.ru"
	q := url.Values{"url": {"https://example.com/releases/app.zip"}}

	req, _ := http.NewRequest(http.MethodGet, ru+"/v1/fetch?"+q.Encode(), nil)
	req.Header.Set("X-Api-Key", key)
	req.Header.Set("X-Chain", "ru->de")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	f, _ := os.Create("app.zip")
	defer f.Close()
	io.Copy(f, res.Body)
}
<?php
$key = 'pk_live_...';
$ru = 'https://ru.proksusha.ru';
$target = rawurlencode('https://example.com/releases/app.zip');

$ch = curl_init("$ru/v1/fetch?url=$target");
curl_setopt_array($ch, [
  CURLOPT_HTTPHEADER => [
    "X-Api-Key: $key",
    'X-Chain: ru->de',
  ],
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_RETURNTRANSFER => true,
]);
$body = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($code >= 400) throw new RuntimeException("HTTP $code");
file_put_contents('app.zip', $body);

2. Fetch direct с de

curl -L \
  -H "X-Api-Key: $KEY" \
  -H "X-Proxy-Mode: direct" \
  -H "X-Exit-Node: de" \
  "https://de.proksusha.ru/v1/fetch?url=https://example.com/releases/app.zip" \
  -o app.zip
import httpx

KEY = "pk_live_..."
DE = "https://de.proksusha.ru"

r = httpx.get(
    f"{DE}/v1/fetch",
    params={"url": "https://example.com/releases/app.zip"},
    headers={
        "X-Api-Key": KEY,
        "X-Proxy-Mode": "direct",
        "X-Exit-Node": "de",
    },
    follow_redirects=True,
)
r.raise_for_status()
open("app.zip", "wb").write(r.content)
import { writeFile } from "node:fs/promises";

const KEY = "pk_live_...";
const DE = "https://de.proksusha.ru";
const target = encodeURIComponent("https://example.com/releases/app.zip");

const res = await fetch(`${DE}/v1/fetch?url=${target}`, {
  headers: {
    "X-Api-Key": KEY,
    "X-Proxy-Mode": "direct",
    "X-Exit-Node": "de",
  },
});
await writeFile("app.zip", Buffer.from(await res.arrayBuffer()));
req, _ := http.NewRequest(http.MethodGet, de+"/v1/fetch?"+q.Encode(), nil)
req.Header.Set("X-Api-Key", key)
req.Header.Set("X-Proxy-Mode", "direct")
req.Header.Set("X-Exit-Node", "de")
res, err := http.DefaultClient.Do(req)
$ch = curl_init("$de/v1/fetch?url=$target");
curl_setopt_array($ch, [
  CURLOPT_HTTPHEADER => [
    "X-Api-Key: $key",
    'X-Proxy-Mode: direct',
    'X-Exit-Node: de',
  ],
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_RETURNTRANSFER => true,
]);

3. OpenAI через /v1/proxy

curl -X POST \
  "$RU/v1/proxy?url=https://api.openai.com/v1/chat/completions" \
  -H "X-Api-Key: $KEY" \
  -H "X-Upstream-Authorization: Bearer sk-OPENAI_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Chain: ru->de" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role":"user","content":"hi"}]
  }'
import httpx

KEY = "pk_live_..."
OPENAI = "sk-OPENAI_KEY"
RU = "https://ru.proksusha.ru"

r = httpx.post(
    f"{RU}/v1/proxy",
    params={"url": "https://api.openai.com/v1/chat/completions"},
    headers={
        "X-Api-Key": KEY,
        "X-Upstream-Authorization": f"Bearer {OPENAI}",
        "Content-Type": "application/json",
        "X-Chain": "ru->de",
    },
    json={
        "model": "gpt-4o-mini",
        "messages": [{"role": "user", "content": "hi"}],
    },
)
r.raise_for_status()
print(r.json())
const KEY = "pk_live_...";
const OPENAI = "sk-OPENAI_KEY";
const RU = "https://ru.proksusha.ru";
const target = encodeURIComponent(
  "https://api.openai.com/v1/chat/completions",
);

const res = await fetch(`${RU}/v1/proxy?url=${target}`, {
  method: "POST",
  headers: {
    "X-Api-Key": KEY,
    "X-Upstream-Authorization": `Bearer ${OPENAI}`,
    "Content-Type": "application/json",
    "X-Chain": "ru->de",
  },
  body: JSON.stringify({
    model: "gpt-4o-mini",
    messages: [{ role: "user", content: "hi" }],
  }),
});
console.log(await res.json());
body := strings.NewReader(`{
  "model":"gpt-4o-mini",
  "messages":[{"role":"user","content":"hi"}]
}`)
q := url.Values{"url": {"https://api.openai.com/v1/chat/completions"}}
req, _ := http.NewRequest(http.MethodPost, ru+"/v1/proxy?"+q.Encode(), body)
req.Header.Set("X-Api-Key", key)
req.Header.Set("X-Upstream-Authorization", "Bearer sk-OPENAI_KEY")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Chain", "ru->de")
res, err := http.DefaultClient.Do(req)
$payload = json_encode([
  'model' => 'gpt-4o-mini',
  'messages' => [['role' => 'user', 'content' => 'hi']],
]);
$target = rawurlencode('https://api.openai.com/v1/chat/completions');

$ch = curl_init("$ru/v1/proxy?url=$target");
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => $payload,
  CURLOPT_HTTPHEADER => [
    "X-Api-Key: $key",
    "X-Upstream-Authorization: Bearer $openai",
    'Content-Type: application/json',
    'X-Chain: ru->de',
  ],
  CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch);

4. Telegram Bot API

curl \
  -H "X-Api-Key: $KEY" \
  -H "X-Chain: ru->de" \
  "$RU/v1/proxy?url=https://api.telegram.org/bot$BOT_TOKEN/getMe"
import httpx, os

r = httpx.get(
    f"{RU}/v1/proxy",
    params={"url": f"https://api.telegram.org/bot{os.environ['BOT_TOKEN']}/getMe"},
    headers={"X-Api-Key": KEY, "X-Chain": "ru->de"},
)
print(r.json())
const bot = process.env.BOT_TOKEN;
const target = encodeURIComponent(
  `https://api.telegram.org/bot${bot}/getMe`,
);
const res = await fetch(`${RU}/v1/proxy?url=${target}`, {
  headers: { "X-Api-Key": KEY, "X-Chain": "ru->de" },
});
console.log(await res.json());
tg := "https://api.telegram.org/bot" + os.Getenv("BOT_TOKEN") + "/getMe"
q := url.Values{"url": {tg}}
req, _ := http.NewRequest(http.MethodGet, ru+"/v1/proxy?"+q.Encode(), nil)
req.Header.Set("X-Api-Key", key)
req.Header.Set("X-Chain", "ru->de")
res, err := http.DefaultClient.Do(req)
$tg = 'https://api.telegram.org/bot' . getenv('BOT_TOKEN') . '/getMe';
$target = rawurlencode($tg);
$ch = curl_init("$ru/v1/proxy?url=$target");
curl_setopt_array($ch, [
  CURLOPT_HTTPHEADER => ["X-Api-Key: $key", 'X-Chain: ru->de'],
  CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch);

5. CDN origin → /o/{slug}

Создание origin (JWT кабинета):

curl -X POST "$RU/v1/origins" \
  -H "Authorization: Bearer $JWT" \
  -H "Content-Type: application/json" \
  -d '{
    "slug": "jsdelivr",
    "target_base": "https://cdn.jsdelivr.net",
    "entry_node": "ru",
    "exit_node": "auto",
    "proxy_mode": "chain"
  }'
import httpx

r = httpx.post(
    f"{RU}/v1/origins",
    headers={"Authorization": f"Bearer {JWT}"},
    json={
        "slug": "jsdelivr",
        "target_base": "https://cdn.jsdelivr.net",
        "entry_node": "ru",
        "exit_node": "auto",
        "proxy_mode": "chain",
    },
)
print(r.json())
const res = await fetch(`${RU}/v1/origins`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${JWT}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    slug: "jsdelivr",
    target_base: "https://cdn.jsdelivr.net",
    entry_node: "ru",
    exit_node: "auto",
    proxy_mode: "chain",
  }),
});
console.log(await res.json());
body := strings.NewReader(`{
  "slug":"jsdelivr",
  "target_base":"https://cdn.jsdelivr.net",
  "entry_node":"ru",
  "exit_node":"auto",
  "proxy_mode":"chain"
}`)
req, _ := http.NewRequest(http.MethodPost, ru+"/v1/origins", body)
req.Header.Set("Authorization", "Bearer "+jwt)
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
$ch = curl_init("$ru/v1/origins");
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer $jwt",
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => json_encode([
    'slug' => 'jsdelivr',
    'target_base' => 'https://cdn.jsdelivr.net',
    'entry_node' => 'ru',
    'exit_node' => 'auto',
    'proxy_mode' => 'chain',
  ]),
  CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch);

В HTML:

<script src="https://ru.proksusha.ru/o/jsdelivr/npm/jquery@3.7.1/dist/jquery.min.js"></script>

6. Ingress (webhook)

curl -X POST "$RU/v1/ingress" \
  -H "Authorization: Bearer $JWT" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "payments",
    "forward_url": "https://backend.example.ru/webhook",
    "entry_node": "ru",
    "proxy_mode": "chain"
  }'
# → token, public_url
# внешняя система: POST https://ru.proksusha.ru/in/$TOKEN
r = httpx.post(
    f"{RU}/v1/ingress",
    headers={"Authorization": f"Bearer {JWT}"},
    json={
        "name": "payments",
        "forward_url": "https://backend.example.ru/webhook",
        "entry_node": "ru",
        "proxy_mode": "chain",
    },
)
data = r.json()  # token, public_url
print(data["public_url"])
const res = await fetch(`${RU}/v1/ingress`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${JWT}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    name: "payments",
    forward_url: "https://backend.example.ru/webhook",
    entry_node: "ru",
    proxy_mode: "chain",
  }),
});
const data = await res.json(); // token, public_url
console.log(data.public_url);
body := strings.NewReader(`{
  "name":"payments",
  "forward_url":"https://backend.example.ru/webhook",
  "entry_node":"ru",
  "proxy_mode":"chain"
}`)
req, _ := http.NewRequest(http.MethodPost, ru+"/v1/ingress", body)
req.Header.Set("Authorization", "Bearer "+jwt)
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
// ответ: token, public_url
$ch = curl_init("$ru/v1/ingress");
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer $jwt",
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => json_encode([
    'name' => 'payments',
    'forward_url' => 'https://backend.example.ru/webhook',
    'entry_node' => 'ru',
    'proxy_mode' => 'chain',
  ]),
  CURLOPT_RETURNTRANSFER => true,
]);
$data = json_decode(curl_exec($ch), true);
echo $data['public_url'];

7. Multi-hop

curl \
  -H "X-Api-Key: $KEY" \
  -H "X-Chain: ru->de->nl" \
  "$RU/v1/proxy?url=https://httpbin.org/get"
r = httpx.get(
    f"{RU}/v1/proxy",
    params={"url": "https://httpbin.org/get"},
    headers={"X-Api-Key": KEY, "X-Chain": "ru->de->nl"},
)
print(r.json())
const target = encodeURIComponent("https://httpbin.org/get");
const res = await fetch(`${RU}/v1/proxy?url=${target}`, {
  headers: { "X-Api-Key": KEY, "X-Chain": "ru->de->nl" },
});
console.log(await res.json());
q := url.Values{"url": {"https://httpbin.org/get"}}
req, _ := http.NewRequest(http.MethodGet, ru+"/v1/proxy?"+q.Encode(), nil)
req.Header.Set("X-Api-Key", key)
req.Header.Set("X-Chain", "ru->de->nl")
res, err := http.DefaultClient.Do(req)
$target = rawurlencode('https://httpbin.org/get');
$ch = curl_init("$ru/v1/proxy?url=$target");
curl_setopt_array($ch, [
  CURLOPT_HTTPHEADER => ["X-Api-Key: $key", 'X-Chain: ru->de->nl'],
  CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch);

8. Кастомный upstream-заголовок

X-Upstream-X-Auth-Token → на target уходит X-Auth-Token.

curl \
  -H "X-Api-Key: $KEY" \
  -H "X-Upstream-X-Auth-Token: secret-from-vendor" \
  -H "X-Chain: ru->de" \
  "$RU/v1/fetch?url=https://vendor.example.com/v1/data"
r = httpx.get(
    f"{RU}/v1/fetch",
    params={"url": "https://vendor.example.com/v1/data"},
    headers={
        "X-Api-Key": KEY,
        "X-Upstream-X-Auth-Token": "secret-from-vendor",
        "X-Chain": "ru->de",
    },
)
print(r.text)
const target = encodeURIComponent("https://vendor.example.com/v1/data");
const res = await fetch(`${RU}/v1/fetch?url=${target}`, {
  headers: {
    "X-Api-Key": KEY,
    "X-Upstream-X-Auth-Token": "secret-from-vendor",
    "X-Chain": "ru->de",
  },
});
console.log(await res.text());
q := url.Values{"url": {"https://vendor.example.com/v1/data"}}
req, _ := http.NewRequest(http.MethodGet, ru+"/v1/fetch?"+q.Encode(), nil)
req.Header.Set("X-Api-Key", key)
req.Header.Set("X-Upstream-X-Auth-Token", "secret-from-vendor")
req.Header.Set("X-Chain", "ru->de")
res, err := http.DefaultClient.Do(req)
$target = rawurlencode('https://vendor.example.com/v1/data');
$ch = curl_init("$ru/v1/fetch?url=$target");
curl_setopt_array($ch, [
  CURLOPT_HTTPHEADER => [
    "X-Api-Key: $key",
    'X-Upstream-X-Auth-Token: secret-from-vendor',
    'X-Chain: ru->de',
  ],
  CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch);