Curl Proxy 101: How to cURL with a proxy?

For those that know how to use it, cURL is a powerful tool. Come in now to learn how to route your cURL requests through proxies.

cURL requests through proxies

Are you a fan of using cURL? What if I tell you that you can access and transfer data unanimously, with your real IP Address masked using these proxies? If you are interested in learning how to get that done, then this article has been written for you.

It is no longer news that Curl, despite its popularity among developers that many of its users do not know how to get it to work with proxies. This is not unconnected to the fact that information on how to get this done is not as common as it should be. It is also related to the fact that the popularity of cURL is reducing gradually as other means of accessing data over a network are being used.


What is cURL?

YouTube video

The cURL library is a command-line utility tool for transferring data using various network protocols. The word is an acronym for Client URL. If this explanation sounds difficult to comprehend, just look at it as a library that allows you to fetch data over the Internet. Some developers use it to access API points. The tool was developed initially for pulling forex rates for IRC users. When it was first released, it was known as urlget. The name later changed to httpget before the current name was adopted. The tool was developed by Daniel Stenberg, a Swedish developer.

The tool has support for a good number of network protocols. It is portable and works on a good number of platforms, including Microsoft Windows, Solaris, macOS, Android, iOS, and a host of over 10 other operating systems. It is also available in many programming languages, including C/C++, Python, Java, and PHP.


How to Set up cURL to Use Proxies

Setting proxies to work with cURL is actually easy. Before showing you how to set things up, I need to let you know that most Windows and macOS devices have cURL preinstalled. All you need to do is make use of it. To make use of proxies with cURL, all that is required is a variable in the cURL syntax. The variable you use depends on the type of authentication you want to use.


IP Authentication

cURL syntax proxy command
[url-protocol]_PROXY [protocol://][:port]
If you use the proxy, you can use a different type of proxy protocols, including HTTP(s) and Socks4/5,

http://
https://
socks4://
socks5://
socks4a://
socks5h://

Many proxy service providers allow their users to authenticate by whitelisting their device real IP Addresses with the proxies they intend to use. With this setting in place, there is no need to make use of username and password for authentication again. This method is the simplest in terms of cURL syntax. The command to use is the -x command or -proxy command. The full command is written below.

Curl -x [proxy protocol][:port]

For example, let say you want to use 123.45.34.32:4325 proxy and you have already whitelisted your real device’s IP with the proxy, all you need to do is to type the following command.

Curl -x 123.45.34.32:4325 https://ipinfo.io

The last command is not part of the command, for setting proxies, it is a get request to a website that displays the IP Address user is using to access the Internet. It is there so that you can actually test if your proxy setting works or not. Remember, I said aside from the -x command; you can use -proxy command too.


Username and Password Authentication

Username and Password Authentication Curl
Curl -U [username:password] -x [proxy protocol][:port]
While IP Authentication seems to be the easiest, it is important you know that the username and password form of authentication is still the most predominant in the industry. While most providers provide username and password authentication, such cannot be said of IP Authentication. If you are going to be authenticating using username and password, in addition to the -x command, you also have to introduce the -U command.

Curl -U [username:password] -x [proxy protocol][:port]

Using the same imaginary proxy port and address used above, we create a text command

Curl -U [user12:oapwe] -x 123.45.34.32:4325 https://ipinfo.io

Yes, It's so easy, now you know how to Curl for private proxy or dedicated IP proxy If you want to learn CURL for proxy lists you can learn from this post, Now there are lots of paid Proxy API for IP rotation, let me show you how to use that.


Curl Proxy API Code

 
curl --proxy zproxy.lum-superproxy.io:22225 --proxy-user lum-customer-usernam:password "http://lumtest.com/myip.json"
 
$ curl http://httpbin.org/get \
      -U 77409f72fe0c4a3e8413654411de0380: \
      -x proxy.crawlera.com:8010
 
curl "http://api.scraperapi.com?api_key=3ff1f5e972791859ac9960827414be23&url=http://httpbin.org/ip"
 
curl "http://api.scraperapi.com?api_key=3ff1f5e972791859ac9960827414be23&url=http://httpbin.org/ip"

Use of Curl in Internet marketing

The truth is, curl is not as popular as it used to be. Unlike in the past were a good number of developers incorporate it into systems they develop. This is because of the alternatives around.

When developers need to test the functionality of their API endpoints now, they either make use of Postman or other GUI tools for such. Some will choose to use a simple tool like wget for this instead of using curl that is complicated. However, a good number of Internet marketers still use it.

Curl in Internet marketing

Currently, aside from some high-end systems, the major use of the curl library in Internet marketing is testing. Usually, before one uses proxies for web scraping and other automation activities, the proxies need to be tested to ascertain their functionalities. Curl is used for that.


Conclusion

From the above, you can tell that it is actually easy, using accessing web endpoints with curl through proxies. the command to use is quite easy to remember. However, I feel it is time to move on and use better tools for this.

Popular Proxy Resources