/cURL-with-proxy

Examples about how to use cURL with proxy, including some examples using cURL commands to connect YiLu Socks5 and HTTP proxy IPs.

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 proxy. cURL with 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.
cURL with Proxy

B. Unzip the file.

cURL with Proxy
cURL with Proxy

C. Configure environment variables

a. Right-click this PC, click "Properties".
cURL with Proxy
b. Enter "Advanced system settings".
cURL with Proxy
c. Enter "Advanced", click "Environment Variables".
cURL with Proxy
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 with Proxy
e. Edit system variable path.
-Select the Path variable
-Click "Edit"
-Click "New"
-Enter "%CURL_HOME%\I386"
-Click "OK" to save.
cURL with Proxy

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].
cURL with Proxy
Enter "curl --version" to check the installation status.
If some curl information appears, that means the CURL’s installation has been successful.
cURL with Proxy

2. cURL set proxy commands.

This is cURL command with proxy:
-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.
curl -x "http://username:password@ip:port" "https://ipinfo.io"
or
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.
curl -x "http://username:password@ip:port" "https://ipinfo.io"
or
curl -x "username:password@ip:port" "https://ipinfo.io"

If you want to ignore or bypass proxy, use cURL noproxy command:
curl --noproxy "*" "https://ipinfo.io"

Here are some cURL commands to connect YiLuProxy different types of IPs.
cURL with Proxy

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 with Proxy

curl -x "username:password@ip:port" "https://ipinfo.io"

cURL with Proxy

curl --proxy "http://username:password@ip:port" "https://ipinfo.io"

cURL with Proxy

curl --proxy "username:password@ip:port" "https://ipinfo.io"

cURL with Proxy

curl -x "socks5://username:password@ip:port" "https://ipinfo.io"

cURL with Proxy

curl --proxy "socks5://username:password@ip:port" "https://ipinfo.io"

cURL with Proxy

curl --socks5 "ip:port" "https://ipinfo.io" --proxy-user username:password

cURL with Proxy

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 with Proxy cURL with Proxy

curl --proxy "socks5://127.0.0.1:port" "https://ipinfo.io"

cURL with Proxy cURL with Proxy

curl -x "socks5://127.0.0.1:port" "https://ipinfo.io"

cURL with Proxy cURL with Proxy

The article is from https://yilu.us/integration/how-to-use-curl-with-proxy