Skip to main content
The Center's Directory
Code examples

Use a proxy with curl

Demonstrates HTTP/HTTPS CONNECT and SOCKS5 TCP requests using fixed username and password gateways and environment credentials.

Maintained by the ZZHTTP engineering teamUpdated September 20, 2026

The curl example is suitable for minimal authentication and server health checks. True values are injected only through controlled environment variables or keys.

HTTP/HTTPS

Bash
curl --connect-timeout 10 --max-time 30 \
  --proxy 'http://us.zzhttp.com:7878' \
  --proxy-user "$PROXY_USERNAME:$PROXY_PASSWORD" \
  'https://ipinfo.io/json'

SOCKS5 TCP

Bash
curl --connect-timeout 10 --max-time 30 \
  --proxy 'socks5h://us.zzhttp.com:7878' \
  --proxy-user "$PROXY_USERNAME:$PROXY_PASSWORD" \
  'https://ipinfo.io/json'

Prepare

  • Get the full proxy username and sub-username and password from the console and inject them separately PROXY_USERNAME and PROXY_PASSWORD; Indicative value ab******9Z, p8******K2 Cannot be used for authentication.
  • Avoid displaying passwords in shell history and CI output.

Implementation

  • HTTP proxies can access HTTP or HTTPS targets.
  • SOCKS5 domain name requests socks5h.

Verification steps

  1. Place the real configuration in a controlled environment variable or temporary credential store, without writing the full proxy URL to the script store.
  2. Run HTTP/HTTPS and HTTPS separately socks5h For example, retain connection timeouts and overall timeouts.
  3. Check HTTP status codes and JSON ip, country, region Exports and selected regions were compared with those without the use of agents. Geographical locations are from third-party databases and the results for cities may be biased.

Expected results

  • The command returns successful within the 30-second total timeout, and the output IP in the response is different from the local public IP.
  • socks5h The target domain name is resolved by the proxy side, avoiding passing the domain name to the local DNS first.

Failure border

  • curl exits while parsing the command or proxy URL, indicating that the request has not yet reached the gateway;407 The certification phase is only indicated by the number of points.
  • Successful address detection does not guarantee accessibility to any target, target 403, 429 and business contents are subject to independent judgment.

Security

  • The debug output requires the removal of Proxy-Authorization.
  • Do not paste the entire command with the password into the worksheet.

Did this answer your question?

Feedback is used only to improve the public documentation and does not submit accounts or request information.