របៀបប្រើប្រាស់ proxy ជាមួយ cURL (syntax លើ command-line & ការ debug)
Updated:
កម្មវិធី command-line curl គឺជាមធ្យោបាយលឿនបំផុតដើម្បីផ្ទៀងផ្ទាត់ការ authentication របស់ proxy, ពិនិត្យមើល HTTP response headers និងវាស់ស្ទង់ round-trip latency ពី terminal របស់ Linux, macOS ឬ Windows ដោយប្រើព័ត៌មានសម្ងាត់ ip:port:user:pass នៃ VinaProxy របស់អ្នក។
curl -x http://user:pass@ip:port https://vinaproxy.com/api/my-ip- 1 IP40,000₫
- 5+ IP35,000₫
- 10+ IP25,000₫
- 20+ IP25,000₫
- 50+ IP25,000₫
- 100+ IP25,000₫
- 200+ IP25,000₫
- 500+ IP25,000₫
- 1000+ IP22,000₫
- 2000+ IP20,000₫
- 1 IP40,000₫
- 5+ IP35,000₫
- 10+ IP25,000₫
- 20+ IP25,000₫
- 50+ IP25,000₫
- 100+ IP25,000₫
- 200+ IP25,000₫
- 500+ IP25,000₫
- 1000+ IP22,000₫
- 2000+ IP20,000₫
flag សំខាន់ៗ និងពាក្យបញ្ជា one-liner សម្រាប់ proxy លើ cURL
បញ្ជូន proxy របស់អ្នកតាមរយៈ -x (--proxy) និង -U (--proxy-user) ឬបញ្ចូលគ្នាទៅជា URL http://user:pass@ip:port តែមួយ៖
| កិច្ចការ | ពាក្យបញ្ជា cURL | អ្វីដែលវាបង្ហាញ |
|---|---|---|
| ពិនិត្យ IP ចេញក្រៅ | curl -x http://user:pass@ip:port https://vinaproxy.com/api/my-ip | ត្រឡប់មកវិញនូវ JSON ជាមួយ IPv4 សាធារណៈរបស់ proxy |
| បំបែកព័ត៌មានសម្ងាត់ដាច់ដោយឡែក | curl -x http://ip:port -U "user:pass" https://vinaproxy.com/api/my-ip | មានសុវត្ថិភាពបំផុតនៅពេលពាក្យសម្ងាត់មានតួអក្សរពិសេស |
| ពិនិត្យមើលតែ headers ប៉ុណ្ណោះ | curl -I -x http://user:pass@ip:port https://example.com | ទាញយក HTTP status code និង response headers |
| វាស់ស្ទង់ TTFB latency | curl -s -o /dev/null -w "Connect:%{time_connect}s TTFB:%{time_starttransfer}s\n" -x http://user:pass@ip:port https://example.com | វាស់ស្ទង់ TCP handshake និងថិរវេលាទទួល byte ដំបូង |
គន្លឹះពិសេសសម្រាប់ Windows PowerShell និង shell scripts
- នៅក្នុង Windows PowerShell ជាទូទៅ
curlត្រូវបានកំណត់ alias ទៅInvoke-WebRequest—ត្រូវដំណើរការcurl.exe -x ...ជានិច្ចដើម្បីប្រើ binary ពិតប្រាកដរបស់ cURL - បន្ថែម
-v(verbose) ដើម្បីពិនិត្យមើលការ handshake របស់CONNECTនិងបញ្ជាក់HTTP/1.1 200 Connection established - បញ្ចូល
--connect-timeout 5 --max-time 15ក្នុង cronjobs និង shell scripts ដើម្បីកុំឱ្យគោលដៅយឺតធ្វើឱ្យ pipeline របស់អ្នកគាំង - រក្សាទុក
proxy = "http://user:pass@ip:port"នៅក្នុង~/.curlrcប្រសិនបើអ្នកចង់បាន proxy លំនាំដើមសម្រាប់ការហៅប្រើcurlទាំងអស់
មួយជំហានម្តងៗ
- 1
បើក terminal របស់អ្នក (ឬ cmd / PowerShell លើ Windows)
កុំភ្លេចវាយ
curl.exeប្រសិនបើអ្នកកំពុងស្ថិតនៅក្នុង Windows PowerShell។ - 2
ដំណើរការសំណើតេស្តតាមរយៈ proxy របស់អ្នក
ដំណើរការ
curl.exe -x http://user:pass@ip:port https://vinaproxy.com/api/my-ipដោយប្រើព័ត៌មានសម្ងាត់ VinaProxy របស់អ្នក។ - 3
Debug headers នៃ handshake ជាមួយ -v ប្រសិនបើចាំបាច់
បន្ថែម
-vដើម្បីពិនិត្យមើលProxy-Authorizationheader និង TLS handshake។ - 4
បន្ថែមការការពារ timeout ក្នុង production scripts
បញ្ជូន
--connect-timeout 5 --max-time 15នៅក្នុង shell scripts ស្វ័យប្រវត្តិ។
សំណួរដែលសួរញឹកញាប់
ហេតុអ្វីបានជា `curl -x` បរាជ័យដោយសារកំហុស parameter នៅក្នុង Windows PowerShell?
PowerShell កំណត់ alias ឱ្យ curl ទៅ Invoke-WebRequest។ សូមដំណើរការ curl.exe -x http://user:pass@ip:port ... ជាមួយកន្ទុយ .exe ដើម្បីហៅប្រើ cURL ដើម។
តើ `HTTP/1.1 407 Proxy Authentication Required` មានន័យដូចម្តេចនៅក្នុង `curl -v`?
វាមានន័យថា cURL បានទៅដល់ IP និង port នៃម៉ាស៊ីនបម្រើ proxy ហើយ ប៉ុន្តែឈ្មោះអ្នកប្រើប្រាស់ ឬពាក្យសម្ងាត់ដែលបានបញ្ជូនទៅ -x ឬ -U មិនត្រឹមត្រូវ។
តើខ្ញុំអាចតេស្ត proxy ច្រើនដោយមិនចាំបាច់ដំណើរការ cURL ក្នុង loop បានទេ?
បាន—បិទភ្ជាប់ proxy រហូតដល់ 100 ទៅក្នុង Proxy Checker ឬ Proxy Speed Test លើគេហទំព័ររបស់យើង។
ទទួលបាន HTTP(S) proxy ដែលមាន latency ទាបសម្រាប់ cURL & ឧបករណ៍ CLI
ទទួលបានព័ត៌មានសម្ងាត់ Dedicated IPv4 និង Static ISP ភ្លាមៗនៅទូទាំង 7 ប្រទេស។
ទិញ cURL Proxy