How to use curl with a proxy server
Route curl requests through HTTP, HTTPS, and SOCKS5 proxy servers for debugging and access control.
How to use curl with a proxy server
Route curl requests through HTTP, HTTPS, and SOCKS5 proxy servers for debugging and access control.
Prerequisites
- curl installed.
- A proxy server address and port.
Step-by-Step: Use curl with a Proxy
Route a request through an HTTP proxy with the
-xflag:curl -x http://proxy.example.com:8080 https://api.example.com/dataRoute through a SOCKS5 proxy:
curl -x socks5://127.0.0.1:1080 https://api.example.com/dataAuthenticate with the proxy server:
curl -x http://proxy.example.com:8080 -U proxyuser:proxypass https://api.example.com/dataSet a proxy via environment variable (applies to all curl requests in the session):
export https_proxy=http://proxy.example.com:8080 curl https://api.example.com/data