What is a proxy server?
A proxy server is a system or router that provides a gateway between users and the internet. Therefore, it helps prevent cyber attackers from entering a private network. It is a server, referred to as an “intermediary” because it goes between end-users and the web pages they visit online. This article is all about configuring Proxy Settings on Linux Terminal and Command Line
UNIX-like and Linux systems e.g RHEL, Fedora etc have environment variables i.e http_proxy and https_proxy. They allow us to connect sessions and/or applications via the proxy server. All we need is proxy server IP address (URL) or DNS name and port values. These variables are almost used by all utilities such as http,elinks, lynx, wget, curl and others commands.
Check current Proxy configuration
All we need is proxy server IP address (URL) or DNS name and port values.
If these variables return empty, then it means that. no proxy has been configured in the system and in the current session.
$ echo $http_proxy http://10.180.160.220:8888 $ echo $https_proxy http://10.180.160.220:8888
Configure Proxy from Command Line
Use the below syntax to configure proxy(http and https) from commandline:
# export http_proxy=http://SERVER:PORT/ # export https_proxy=http://SERVER:PORT/
If you need to authenticate with your proxy using a username and password, use the following syntax:
# export http_proxy=http://USERNAME:PASSWORD@SERVER:PORT/ # export https_proxy=http://USERNAME:PASSWORD@SERVER:PORT/
Example
export http_proxy=http://10.180.160.220:8888 export https_proxy=http://10.180.160.220:8888 export no_proxy="localhost, *.technnix.com, 10.*, 172.*"
Note: no_proxy – defines the host names that shouldn’t go through a proxy to access the upstream repository/internet.
Configure Proxy Permanently for all users
The above method will only work for the current session. To persist the configuration for all users, we need to add these entries to the /etc/profile.d/http_proxy.sh file.
Bash and sh users
# echo "http_proxy=http://10.180.160.220:8888/" >> /etc/profile.d/http_proxy.sh # echo "http_proxy=http://10.180.160.220:8888/" >> /etc/profile.d/http_proxy.sh # echo "no_proxy="localhost, *.technnix.com, 10.*, 172.*/" >> /etc/profile.d/http_proxy.sh
C Shell(csh) and tcsh users
# echo "http_proxy=http://10.180.160.220:8888/" >> /etc/profile.d/http_proxy.csh # echo "http_proxy=http://10.180.160.220:8888/" >> /etc/profile.d/http_proxy.csh # echo "no_proxy="localhost, *.technnix.com, 10.*, 172.*/" >> /etc/profile.d/http_proxy.csh