Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

curl

ubuntu

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

like image 470
Ben Avatar asked Sep 26 '11 17:09

Ben


People also ask

How do I use curl with a proxy?

To use a proxy with Curl, you must pass the required proxy address using the -x (or --proxy) command-line option and proxy credentials using the -U (or --proxy-user) command-line switch. Proxy credentials may also be passed in the proxy string and will be URL decoded by Curl.

How do I permanently set a proxy in Linux?

Set up proxy permanently using /etc/profile.Replace http_proxy with https_proxy in the export argument to enable proxy over SSL/TLS. This information will be provided by the Network Team who have provided the proxy server related details.

Does curl respect Http_proxy?

The client curl (naturally) uses the library libcurl under the hood. libcurl respects the proxy environment variables named http_proxy, ftp_proxy, sftp_proxy etc. If set, libcurl will use the specified proxy for that URL scheme.


3 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>
like image 130
Sandro Munda Avatar answered Oct 13 '22 00:10

Sandro Munda


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
like image 31
Peter T Avatar answered Oct 13 '22 00:10

Peter T


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
like image 17
Trevor Avatar answered Oct 13 '22 01:10

Trevor