Skip to main content

How to use a proxy server to access the Internet at Shell prompt with http_proxy variable.

# -----------------------------------------------------------------------------
# How To Use Proxy Server To Access Internet at Shell Prompt
#   http://www.cyberciti.biz/faq/linux-unix-set-proxy-environment-variable/
# -----------------------------------------------------------------------------

##
# 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

# and add the following information:
export http_proxy=http://proxy-server.mycorp.com:3128/

##
# 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/