How to Use cURL with Proxy

Fri Apr 21 2023admin
How to Use cURL with Proxy?
cURL is a command line tool for sending and receiving data using the URL. When you enter a URL that blocked for your location or you want to hide your IP address, you need to connect proxy for cURL. Next, let’s learn how to use cURL with Yilu proxy.
curl setting with yilu proxy
1. Download and install cURL.
A. Download cURL
cURL official website download URL: https://curl.se/download.html
cURL supports Windows, Linux, macOS, and here I use Windows-64bit.
Download into Windows 64-bit System
B. Unzip the file.
curl unzip file 3
curl unzip file 4
C. Configure environment variables
a. Right-click this PC, click "Properties".
curl click pc properties
b. Enter "Advanced system settings".
curl Properties to Advanced system setting
c. Enter "Advanced", click "Environment Variables".
curl Advanced environment variables
d. Add a new user variable.
-Click "New"
-Enter new user variable name: CURL_HOME
-Enter variable value: enter the CURL bin file installation directory, here is
D:\Software\curl-8.0.1_7-win64-mingw\bin
-Click "OK" to save.
curl Add a new user variable
e. Edit system variable path.
-Select the Path variable
-Click "Edit"
-Click "New"
-Enter "%CURL_HOME%\I386"
-Click "OK" to save.
curl Add system variable path
D. Check cURL installation status.
On the computer keyboard, press "Windows" and "R" at the same time to open "Run" box.
Then enter "cmd", and click "OK" to open [Command Prompt].
Check cURL installation status
Enter "curl --version" to check the installation status.
If some curl information appears, that means the CURL’s installation has been successful.
curl check the installation status 12
2. cURL set proxy commands.
This is cURL command with proxy:
1.-x, --proxy [protocol://]host[:port]
Here I use "https:ipinfo.io" to test proxy IP address.
We can use curl -x or curl --proxy to set proxy.
For example: the following two CURL commands is the same.
1.curl -x "http://username:password@ip:port" "https://ipinfo.io"
or
1.curl --proxy "http://username:password@ip:port" "https://ipinfo.io"
cURL default proxy protocol type is HTTP.
For example: the following two cURL commands is the same.
1.curl -x "http://username:password@ip:port" "https://ipinfo.io"
or
2.curl -x "username:password@ip:port" "https://ipinfo.io"
If you want to ignore or bypass proxy, use cURL noproxy command:
1.curl --noproxy "*" "https://ipinfo.io"
Here are some cURL commands to connect YiLuProxy different types of IPs.
cURL commands
The following content is cURL with proxy example, including set cURL HTTP proxy and cURL Socks5 proxy. Here I use YiLu Proxy as cURL proxy, and it supports Socks5 and HTTP protocols.
A. Username and password authorization (For YiLu Proxy dynamic IP and mobile IP)
①curl -x "http://username:password@ip:port" "https://ipinfo.io"
a. On the YiLu Proxy [Residential IPs] or [Pro Mobile IP] tab;
b. Select a YiLu Proxy IP type: dynamic rotating residential IP or datacenter IP, mobile IP, or Pro residential IP;
c. Select the [username:password@IP:port] format;
d. Set the number of generating IPs;
e. Select a country, state, and city;
f. Refresh;
g. Right-click an IP;
h. Copy IP and Port;
i. Enter the curl proxy command; press Enter.
curl command-1 x Username password authorization
②curl -x "username:password@ip:port" "https://ipinfo.io"
curl variable command 2-x-username password ip por
③curl --proxy "http://username:password@ip:port" "https://ipinfo.io"
curl variable command 3 proxy 17
④curl --proxy "username:password@ip:port" "https://ipinfo.io"
curl variable command 4 proxy 18
⑤curl -x "socks5://username:password@ip:port" "https://ipinfo.io"
curl variable command 5 x socks5 19
⑥curl --proxy "socks5://username:password@ip:port" "https://ipinfo.io"
curl variable command 6 proxy socks5 20
⑦curl --socks5 "ip:port" "https://ipinfo.io" --proxy-user username:password.
curl variable command 7 socks5 ip port 21
B. Local port forward (for all YiLu Proxy IPs).
During using the proxy forward port, YiLuProxy client must be running.
For local port forwarding detailed tutorial, please view https://yilu.us/configuration/yilu-proxy-ip-use-tutorial.
⑧curl --socks5 "127.0.0.1:port" "https://ipinfo.io".
Curl variable command 8 local port forward 127001
Curl variable command 8 check local port forward 127001
⑨curl --proxy "socks5://127.0.0.1:port" "https://ipinfo.io"
Curl variable command 9 proxy socks5 127001
Curl variable command 9 check proxy socks5 127001
⑩curl -x "socks5://127.0.0.1:port" "https://ipinfo.io".
Curl command 10 x socks5 127001
Curl command 10 check x socks5 127001

get free trial

download yilu proxy