How To Use Proxy Server To Access Internet at Shell Prompt With http_proxy Variable
Q. I'm behind a squid proxy server. How do I access internet via proxy server when I use wget, lynx and other utilities from a shell prompt?
A. Linux / UNIX has environment variable called http_proxy. It allows you to connect text based session / application via the proxy server. All you need is proxy server IP and port values. This variable is almost used by all utilities such as elinks, lynx, wget, curl and others.
Set http_proxy shell variable
Type the following command to set proxy server:
$ 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/
How do I 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=http://proxy-server.mycorp.com:3128/
Save and close the file.
How do I use password protected proxy server?
You can simply use wget as follows:
$ wget --proxy-user=USERNAME --proxy-password=PASSWORD http://path.to.domain.com/some.html
Lynx has following syntax:
$ lynx -pauth=USER:PASSWORD http://domain.com/path/html.file
Curl has following syntax:
$ curl --proxy-user user:password http://url.com/
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Linux / UNIX FAQ:
- Environment variable changing on Linux/FreeBSD
- How to determine or retrieve visitor’s IP address using PHP
- Squid proxy authentication in transparent mode
- FreeBSD Display Environment Settings
- Commonly used UNIX / Linux commands by new user
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Please do not use the comment form to ask for help / question. Ask your question on the excellent Linux tech support forum. Thank you very much for stopping by our site!
Tags: /etc/profile, access internet, curl command, elinks command, environment variable, export http_proxy, html syntax, http_proxy, ip port, ip proxy, lynx command, lynx proxy server, password protected, password protected proxy server, proxy ip, proxy password, proxy server client setup, proxy user, server proxy, session application, squid, squid proxy server, wget command, wget proxy server ~ Last updated on: May 9, 2008



May 9th, 2008 (1 weeks ago) at 4:07 pm
For password protected proxies, I know it sometimes work directly included in http_proxy variable (ok it’s not so secure but it can make the work easier) :
$ export http_proxy=http://user:password@server-ip:port/
May 9th, 2008 (1 weeks ago) at 4:52 pm
It is really correct?
export export http_proxy=http://proxy-server.mycorp.com:3128/
May 9th, 2008 (1 weeks ago) at 5:45 pm
Slavko,
It was a typo. The faq has been updated.