In a generic scenario, internet access is running through a proxy in small offices. In that case, Linux command line utilities that require internet access to work like wget, curl, yum, and apt-get don't work. The questions that come up:
- How to install packages using proxy by yum?
- How to install packages using proxy by apt-get?
- How to download a file from command line using wget?
All these utilities depend on shell variables http_proxy and ftp_proxy to work with a proxy.
So, to use a proxy server to access http/https from a Linux machine in CLI, set the environment variable http_proxy. This will allow wget, python's urllib modules, and other applications (yum, apt-get, etc) to use this environment variable and access http/https using the settings assigned to the variable http_proxy.
The below would be the ideal way of assigning values for the http_proxy variable:
export http_proxy="http://ipaddress:port"
In the same way, use the ftp_proxy variable to access FTP:
export ftp_proxy="http://ipaddress:port"
Add these two lines to ~/.bashrc so that these variables are exported every time the user logs in to the machine.
Originally published May 16, 2010 on jaymspatel.blogspot.com