Introduction

In this article, we'll explore how to leverage cURL to perform a POST request to a server by using a proxy server. By doing so, we can obtain data while maintaining anonymity and add a level of security through the proxy.

Performing a POST request with cURL involves specifying:

  • the target URL
  • the data to be sent
  • and any additional parameters such as:
    • headers
    • authentication tokens

Additionally, we can configure cURL to use a proxy server to anonymize our request and hide our true IP address.

cURL Example

Let's illustrate this concept with a practical example. Testing the cURL with the current IP address can be done by:

curl https://api.ipify.org?format=json && echo

cURL and proxy

Assume we want to retrieve geolocation data for some IP address using the IPinfo API and a proxy server located at "proxy.example.com:8080". We can achieve this with the following cURL command:

curl -x proxy.example.com:8080 -d '{"ip": "8.8.8.8"}' https://ipinfo.io/post

In this command:

  • -x proxy.example.com:8080 specifies the proxy server and port to use.
  • -d '{"ip": "8.8.8.8"}' sends the IP address "8.8.8.8" as JSON data in the POST request body.
  • https://ipinfo.io/post is the target URL for the POST request.

Free proxy lists

To get free proxy samples we can use the following resources:

cURL and http proxy

Below you can find several examples of cURL command using http addresses obtained from the resources above:

curl -x http://34.126.125.90:8080 http://api.ipify.org?format=json && echo

curl -x http://3.101.73.107:1080 http://api.ipify.org?format=json && echo

curl -x http://117.250.3.58:8080 http://api.ipify.org?format=json && echo

the result is:

{"ip":"3.101.73.107"}

cURL and socks5 proxy

To use socks5 proxy we need to add parameter --socks5:

curl --socks5 72.195.34.35:27360 http://api.ipify.org?format=json && echo

result:

{"ip":"72.195.34.35"}

cURL, proxy, user and password

Finally to use the cURL command with user and password use the following syntax:

curl -x --socks5 72.195.34.35:27360 --proxy-user theuser:thepass -L https://ipinfo.io/

or we can use alternative syntax:

curl -x http://<user>:<pass>@<proxyhost>:<port>/ -o <filename> -L <link>

Conclusion

In this short post you learn how to use cURL commands with different proxy types. You also learn how to find free proxies for testing purposes.

Before using any of those read the terms of use of any of them.

Resources