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.
1. Download and install cURL.
A. Download cURL
cURL supports Windows, Linux, macOS, and here I use Windows-64bit.
B. Unzip the file.
C. Configure environment variables
a. Right-click this PC, click "Properties".
b. Enter "Advanced system settings".
c. Enter "Advanced", click "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.
e. Edit system variable path.
-Select the Path variable
-Click "Edit"
-Click "New"
-Enter "%CURL_HOME%\I386"
-Click "OK" to save.
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].
Enter "curl --version" to check the installation status.
If some curl information appears, that means the CURL’s installation has been successful.
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.
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 -x "username:password@ip:port" "https://ipinfo.io"
③curl --proxy "http://username:password@ip:port" "https://ipinfo.io"
④curl --proxy "username:password@ip:port" "https://ipinfo.io"
⑤curl -x "socks5://username:password@ip:port" "https://ipinfo.io"
⑥curl --proxy "socks5://username:password@ip:port" "https://ipinfo.io"
⑦curl --socks5 "ip:port" "https://ipinfo.io" --proxy-user username:password.
B. Local port forward (for all YiLu Proxy IPs).
During using the proxy forward port, YiLuProxy client must be running.
⑧curl --socks5 "127.0.0.1:port" "https://ipinfo.io".
⑨curl --proxy "socks5://127.0.0.1:port" "https://ipinfo.io"
⑩curl -x "socks5://127.0.0.1:port" "https://ipinfo.io".