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=http://127.0.0.1:3128/ $ export http_proxy=http://proxy-server.mycorp.com:3128/
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:firstname.lastname@example.org:3128/ $ export http_proxy=http://USERNAME:PASSWORD@proxy-server.mycorp.com:3128/
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:
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 http://path.to.domain.com/some.html
Lynx command has the following syntax:
$ lynx -pauth=USER:PASSWORD http://domain.com/path/html.file
Curl command has following syntax:
$ curl –proxy-user user:password http://url.com/