Setting proxies with http_proxy variable

Using proxies to access sites blocked by your organization is a common thing. Problem arises for people who loves to work in command-based environment and browse internet in terminal itself. This post solves their problem.

Linux and other Unix-based systems have environment variable http_proxy which is used by internet command line utilities like curl,wget,lynx etc. All you need is proxy server IP address (URL) and port values.

Setting up the http_proxy variable:

Fire up you shell and type in following

$ export http_proxy=http://server-ip:port/

$ export http_proxy=

$ export http_proxy=

If the proxy server requires a username and password then add these to the URL. For example, to include the username foo and the password bar:

$ export http_proxy=http://foo:bar@server-ip:port/

$ export http_proxy=http://foo:bar@

$ export http_proxy=

How to setup proxy variable for all users?

To setup the proxy environment variable as a global variable, open /etc/profile file:

$ vi /etc/profile

Add the following information:

export http_proxy=


export http_proxy=

Save and close the file.

How do I use password protected proxy server using various command line options?

You can simply use wget command as follows:

$ wget –proxy-user=USERNAME –proxy-password=PASSWORD

Lynx command has the following syntax:

$ lynx -pauth=USER:PASSWORD

Curl command has following syntax:

$ curl –proxy-user user:password


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s