How do I set up curl to permanently use a proxy?

LinuxUbuntuCurl

Linux Problem Overview


How can I set up "curl" to permanently use a proxy server in the terminal?

Linux Solutions


Solution 1 - Linux

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>

Solution 2 - Linux

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

Solution 3 - Linux

Curl 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

Solution 4 - Linux

One notice. On Windows, place your _curlrc in '%APPDATA%' or '%USERPROFILE%\Application Data'.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBenView Question on Stackoverflow
Solution 1 - LinuxSandro MundaView Answer on Stackoverflow
Solution 2 - LinuxPeter TView Answer on Stackoverflow
Solution 3 - LinuxTrevorView Answer on Stackoverflow
Solution 4 - LinuxfeechView Answer on Stackoverflow