Налаштування проксі у cURL
Спрямовуйте запити cURL через SotaProxy одним флагом.
cURL підтримує проксі нативно через флаг -x. Одне доповнення команди - і кожен запит іде через SotaProxy. Зручно для перевірки з’єднання через проксі, швидких вивантажень даних і shell-скриптів.
Посібник із налаштування
Базовий запит через проксі
curl -x "http://YOUR_USERNAME:YOUR_PASSWORD@proxy.sotaproxy.com:10000" \
https://httpbin.org/ipФлаг -x задає проксі. Включіть облікові дані в URL. Працює і для HTTP-, і для HTTPS-цілей.
Гео-таргетинг
# US IP
curl -x "http://YOUR_USERNAME_c_US:YOUR_PASSWORD@proxy.sotaproxy.com:10000" \
https://httpbin.org/ip
# German IP
curl -x "http://YOUR_USERNAME_c_DE:YOUR_PASSWORD@proxy.sotaproxy.com:10000" \
https://httpbin.org/ipДодайте _c_XX до імені користувача. Використовуйте дволітерні коди ISO великими літерами.
Задати через змінну оточення
export HTTPS_PROXY="http://YOUR_USERNAME:YOUR_PASSWORD@proxy.sotaproxy.com:10000"
export HTTP_PROXY="http://YOUR_USERNAME:YOUR_PASSWORD@proxy.sotaproxy.com:10000"
# Now all curl requests use the proxy
curl https://httpbin.org/ipВстановлення змінних оточення спрямовує всі запити curl через проксі без указування -x щоразу.
SOCKS5-проксі
curl --socks5 "proxy.sotaproxy.com:SOCKS5_PORT" \
-U "YOUR_USERNAME:YOUR_PASSWORD" \
https://httpbin.org/ipДля SOCKS5 використовуйте --socks5 замість -x. Уточніть SOCKS5-порт у дашборді SotaProxy.
Автоматизуй через SotaProxy API
Усе описане вище працює без відкриття дашборда. З API-ключем cURL може отримувати свіжі дані проксі, купувати нові та продовжувати ті, що спливають, - прямо з коду.
# Every active proxy on your account (ip, ports, login, password as JSON)
curl -H "Authorization: Bearer $KEY" https://api.sotaproxy.com/api/v1/proxies
# Buy more when you scale (price-check first with POST /quote)
curl -X POST https://api.sotaproxy.com/api/v1/orders \
-H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-H "Idempotency-Key: my-unique-order-id" \
-d '{"product":"ipv4","countryId":565,"periodId":"1m","quantity":5}'Flags that matter
curl is the fastest way to prove an address works before you write any code. Both of our address types plug in the same way:
Put credentials in the -x argument or keep them out of shell history with --proxy-user and a netrc file.
Checking what the target sees
Three commands worth keeping around: confirm the exit address, confirm geography, confirm the session holds:
Shell: verify address, geography and stickiness
# which address are we leaving from
curl -x login_c_US:password@proxy.sotaproxy.com:10000 https://api.ipify.org
# what the target sees about that address
curl -x login_c_DE:password@proxy.sotaproxy.com:10000 https://ipinfo.io/json
# does the sticky session hold across calls
for i in 1 2 3; do
curl -s -x login_c_US_s_9_ttl_15m:password@proxy.sotaproxy.com:10000 https://api.ipify.org
echo
done
# SOCKS5 with DNS resolved on our side
curl -x socks5h://login:password@proxy.sotaproxy.com:10000 https://api.ipify.org- Three identical answers from the sticky loop mean the session works. Three different ones mean a suffix is malformed and you silently got rotation.
- Add -v when something is wrong. The proxy handshake is visible there and a 407 is unmistakable.
- Use --compressed to ask for gzip and save residential traffic while testing.
- For static addresses drop the suffixes entirely and point curl at your-ip:50100, or 50101 for SOCKS5.
curl specifics
socks5 versus socks5h
The first resolves DNS locally, which leaks the target to your resolver and breaks geo-sensitive routing. The h variant resolves remotely.
Passwords in shell history
Anything typed after -x lands in .bash_history. Use --proxy-user with netrc when the machine is shared.
Confusing 407 with a target error
A 407 comes from us and means the login string did not parse. The target never saw the request.
Testing with http:// on an https target
Both go through the same endpoint, but mixing schemes in scripts causes confusing redirects. Match the scheme to the target.
Нотатки та поради
- •Перевірте з’єднання перед використанням у продакшені: curl -x "proxy_url" https://httpbin.org/ip
- •--proxy-insecure пропускає перевірку TLS для з’єднання з проксі (не з ціллю) - використовуйте лише для налагодження.
- •cURL враховує змінні оточення HTTP_PROXY і HTTPS_PROXY. Задайте їх у профілі оболонки для постійної конфігурації.
FAQ
Як перевірити IP проксі у cURL?
Виконайте: curl -x "http://user:pass@proxy.sotaproxy.com:10000" https://httpbin.org/ip - відповідь покаже IP проксі, а не ваш.
Чи можна використовувати проксі cURL у shell-скриптах?
Так. Задайте HTTP_PROXY і HTTPS_PROXY як змінні оточення на початку скрипта або передавайте -x у кожен виклик curl.
Схожі інтеграції
Отримай облікові дані проксі
Зареєструйся, поповни баланс і скопіюй ендпоінт у cURL. Займе менше 5 хвилин.
Почати