How to Use Linux curl with HTTP and SOCKS Proxies and Test Anonymity Levels
This guide explains proxy server types, shows how to configure Linux curl for HTTP, HTTPS, and SOCKS4/4A/5 proxies with authentication options, provides concrete command examples, and demonstrates a method for testing the anonymity of each proxy type using a PHP script.
1. Types of Proxy Servers
Proxy servers sit between a browser and an HTTP server. They are mainly divided into HTTP proxies (transparent, anonymous, high‑anonymous) and SOCKS proxies (SOCKS4, SOCKS4A, SOCKS5). HTTP proxies forward HTTP(S) traffic only, while SOCKS proxies can forward any TCP/UDP protocol and support features such as server‑side DNS resolution, multiple authentication methods, and IPv6.
2. curl Proxy Options on Linux
curl provides several parameters to configure proxies: -x host:port or --proxy protocol://[user:pwd@]host[:port] – specify an HTTP/HTTPS proxy (default port 8080 if omitted). --socks4 host[:port], --socks4a host[:port], --socks5 host[:port] – use SOCKS4, SOCKS4A, or SOCKS5 proxies; these options override -x. --proxy-user user:password or -U user:password – supply proxy authentication credentials. --proxy-anyauth, --proxy-basic, --proxy-ntlm, etc. – select the proxy authentication method.
3. Example Commands
HTTP proxy
# Set HTTP proxy IP and port
curl -x 113.185.19.192:80 http://example.com/test.php
# Use explicit protocol syntax
curl --proxy http_proxy://aiezu:[email protected]:80/http://example.com/test.php
# Basic authentication (username:password)
curl -x aiezu:[email protected]:80 http://example.com/test.php
curl -x 113.185.19.192:80 -U aiezu:123456 http://example.com/test.php
curl -x 113.185.19.192:80 --proxy-user aiezu:123456 http://example.com/test.php
# NTLM authentication
curl -x 113.185.19.192:80 -U aiezu:123456 --proxy-ntlm http://example.com/test.phpSOCKS proxy
# SOCKS4 proxy (no authentication)
curl --socks4 122.192.32.76:7280 http://example.com/test.php
# SOCKS4A proxy (server‑side DNS)
curl --socks4a 122.192.32.76:7280 http://example.com/test.php
# SOCKS5 proxy with basic authentication
curl --socks5 122.192.32.76:7280 -U aiezu:123456 http://example.com/test.php
# SOCKS5 proxy with NTLM authentication
curl -x socks5:122.192.32.76:7280 -U aiezu:123456 --proxy-ntlm http://example.com/test.php4. Testing Proxy Anonymity
Create a PHP file test.php in the web root that prints selected $_SERVER variables (e.g., REMOTE_ADDR, HTTP_X_FORWARDED_FOR, HTTP_VIA, etc.). Access the file in the following ways and compare the output:
Without a proxy.
Through a transparent HTTP proxy.
Through an anonymous HTTP proxy.
Through a high‑anonymous HTTP proxy.
Through SOCKS4, SOCKS4A, and SOCKS5 proxies.
Typical results:
Transparent proxy: REMOTE_ADDR shows the proxy IP, original client IP appears in HTTP_X_FORWARDED_FOR, and HTTP_VIA indicates proxy usage.
Anonymous proxy: REMOTE_ADDR shows the proxy IP, original IP is not disclosed, but HTTP_PROXY_CONNECTION reveals that a proxy was used.
High‑anonymous proxy (HTTP or SOCKS5): Only REMOTE_ADDR changes to the proxy IP; no additional headers expose proxy usage, confirming true anonymity.
This procedure demonstrates how to configure curl for different proxy types, how to supply credentials, and how to verify the anonymity level of each proxy.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
