How can I set up "curl" to permanently use a proxy server in the terminal?
- 38why was this question closed? seems quite important to me...Deepend– Deepend2013-07-08 15:40:06 +00:00Commented Jul 8, 2013 at 15:40
- 1I suspect it was considered off topic because it did not explicitly mention how cURL was being used in a programming problem (e.g. writing a script to do something interesting). It might have just as well been formulated as a sysadmin question better suited to ServerFault.jacobq– jacobq2015-08-10 20:56:16 +00:00Commented Aug 10, 2015 at 20:56
- 1stackoverflow.com/questions/9445489/…David– David2016-11-14 08:42:06 +00:00Commented Nov 14, 2016 at 8:42
4 Answers
You can make a alias in your ~/.bashrc file :
alias curl="curl -x <proxy_host>:<proxy_port>" Another solution is to use (maybe the better solution) the ~/.curlrc file (create it if it does not exist) :
proxy = <proxy_host>:<proxy_port> 5 Comments
alias curl=curl --proxy <proxy server:port> $*Many UNIX programs respect the http_proxy environment variable, curl included. The format curl accepts is [protocol://]<host>[:port].
In your shell configuration:
export http_proxy http://proxy.server.com:3128 For proxying HTTPS requests, set https_proxy as well.
Curl also allows you to set this in your .curlrc file (_curlrc on Windows), which you might consider more permanent:
http_proxy=http://proxy.server.com:3128 3 Comments
export https_proxy=https://proxy.server.com:6443Curl will look for a .curlrc file in your home folder when it starts. You can create (or edit) this file and add this line:
proxy = yourproxy.com:8080 2 Comments
One notice. On Windows, place your _curlrc in '%APPDATA%' or '%USERPROFILE%\Application Data'.