Wednesday, September 19, 2007

The "http_proxy" environment variable - Setup proxy setting in a linux machine.

If you need to use proxy server to access http/https from a linux machine in the office LAN, set the environment variable http_proxy. This will allow wget and 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 http_proxy variable.

$export http_proxy="http://<proxy-server-ip>:<port>"

I have added this to my ~/.bashrc so that I don't have to export this variable every time I reboot my machine !

And then there is the "ftp_proxy" .....

7 comments:

cristian said...

And if my proxy server has user and password authentication ?

Trishito said...

for passing the credentials use the following:-

#export HTTP_PROXY=http://username:password@host:port

kryptoz said...

Cristian, Trishito got the answer for you!

Thanks Trishito!

shreyas said...

what if the password contains special characters, like an '@'??

McMaster said...

if you have a special character, such as '@', you would escape it with the escape character '\'. i.e. user:p\@ssword@host:port

shreyas said...

unfortunately, escaping doesnt work in case of apt.
this was a bug logged against this (#500560) in debian bug repository. i have fixed it and have uploaded the patches.
alternatively, they are also available at my blog - http://pyarabola.wordpress.com/2009/03/01/setting-up-debian-apt-behind-proxy-server/

datak said...

You can set other env. vars. :

set HTTP_PROXY_USER=username



set HTTP_PROXY_PASS=password

to solve that.

Graatings. Check what is happening in London (G-20) !!