cURL ile Proxy Kullanımı
cURL, HTTP için güçlü bir komut satırı aracıdır. Tüm proxy türlerini mükemmel şekilde destekler.
Temel Söz Dizimi
curl -x [protocol://]host:port URL
HTTP Proxy
# Proxy üzerinden basit istek
curl -x http://proxy.example.com:8080 https://httpbin.org/ip
# Kimlik doğrulama ile
curl -x http://user:[email protected]:8080 https://httpbin.org/ip
# Veya ayrı olarak
curl -x http://proxy.example.com:8080 -U user:password https://httpbin.org/ip
HTTPS Proxy
curl -x https://proxy.example.com:8080 https://httpbin.org/ip
SOCKS Proxy
# SOCKS4
curl --socks4 proxy.example.com:1080 https://httpbin.org/ip
# SOCKS4A (DNS proxy üzerinden)
curl --socks4a proxy.example.com:1080 https://httpbin.org/ip
# SOCKS5
curl --socks5 proxy.example.com:1080 https://httpbin.org/ip
# DNS proxy üzerinden SOCKS5 (önerilir)
curl --socks5-hostname proxy.example.com:1080 https://httpbin.org/ip
Ortam Değişkenleri
# Proxy'yi genel olarak ayarla
export http_proxy=http://proxy.example.com:8080
export https_proxy=http://proxy.example.com:8080
# Artık tüm istekler proxy üzerinden gider
curl https://httpbin.org/ip
# Belirli host'lar için proxy'yi yok say
export no_proxy=localhost,127.0.0.1,.internal.com
Kullanışlı Seçenekler
# Bağlantı süresini göster
curl -x http://proxy:8080 -w "Time: %{time_total}s\n" https://httpbin.org/ip
# SSL hatalarını yok say
curl -x http://proxy:8080 -k https://example.com
# Zaman aşımı ayarla
curl -x http://proxy:8080 --connect-timeout 10 https://httpbin.org/ip
# Yönlendirmeleri takip et
curl -x http://proxy:8080 -L https://httpbin.org/redirect/3
# Çerezleri kaydet
curl -x http://proxy:8080 -c cookies.txt https://example.com
# POST isteği gönder
curl -x http://proxy:8080 -X POST -d "data=value" https://httpbin.org/post
Proxy Listesi Kontrol Betiği
#!/bin/bash
while read proxy; do
result=$(curl -x "$proxy" -s --connect-timeout 5 https://httpbin.org/ip)
if [ $? -eq 0 ]; then
echo "[OK] $proxy"
else
echo "[FAIL] $proxy"
fi
done < proxies.txt
Hata Ayıklama
# Ayrıntılı çıktı
curl -x http://proxy:8080 -v https://httpbin.org/ip
# Yalnızca başlıkları göster
curl -x http://proxy:8080 -I https://httpbin.org/ip
