Table of Contents
In this article I will share the steps to set up proxy server using https_proxy and https_proxy environment variable.
What is Proxy Server?
A proxy server is a dedicated computer or a software system running on a computer that acts as an intermediary between an endpoint device, such as a computer, and another server from which a user or client is requesting a service. The proxy server may exist in the same machine as a firewall server or it may be on a separate server, which forwards requests through the firewall.
Check current proxy configuration status (https_proxy/https_proxy)
This variable will show if there is a proxy server configured on the system:
# echo $http_proxy # echo $https_proxy
If these variables are empty it would mean that there are no proxy servers configured on the system level.
Set up proxy server using http_proxy environment variable
https_proxy environment variable is used to specify proxy settings to client programs such as
Set up proxy without username and password
Execute the below command with valid
PORT on the terminal. This will enable proxy configuration for the current session but these values will not be persistent across reboot.
# export http_proxy=http://SERVER:PORT/
Set up proxy with username and password
You can modify the earlier command to add the username and password value assuming a valid authentication is required to enable the proxy server configuration. But again this command will also enable proxy server for the current session only and will not be persistent across reboots.
# export http_proxy=http://USERNAME:PASSWORD@SERVER:PORT/
Set up proxy with domain, username and password
Assuming you are also required to add domain detail while setting up proxy configuration on your system then use the below command
# export http_proxy=http://DOMAIN\\USERNAME:PASSWORD@SERVER:PORT/
Special character (@) handling
When the username or password uses the @ symbol, add a backslash (\) before the @ – for example:
Set up proxy permanently using /etc/environment
Now as I have highlighted above the above commands will work only for the current active session but will not be available across reboots. So to make these changes persistent define the environment variables in
# echo "http_proxy=http://proxy.example.com:3128/" > /etc/environment
Set up proxy permanently using /etc/profile.d
sh users, add the export line given above into a new file called
# echo "export http_proxy=http://proxy.example.com:3128/" > /etc/profile.d/http_proxy.sh
tcsh users, use the following command to set the
http_proxy variable in a new file called
# echo "setenv http_proxy http://proxy.example.com:3128/" > /etc/profile.d/http_proxy.csh
The extension of these files determines which shell will read them. The commands are not interchangeable.
Lastly I hope the steps from the article to setup proxy using http_proxy and https_proxy environment variable in Linux was helpful. So, let me know your suggestions and feedback using the comment section.