How to setup proxy linux

How to set up proxy using http_proxy & https_proxy environment variable in Linux?

In this article I will share the steps to set up proxy server using https_proxy and https_proxy environment variable.

How to set up proxy using http_proxy & https_proxy environment variable in Linux?

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

The http_proxy and https_proxy environment variable is used to specify proxy settings to client programs such as curl and wget .

Set up proxy without username and password

Execute the below command with valid SERVER_IP and 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

With more complex and robust handling of special characters in username or password follow How to setup http or https proxy with special characters in username and password

Читайте также:  Create linux user python

When the username or password uses the @ symbol, add a backslash (\) before the @ — for example:

export http_proxy=http://DOMAIN\\USERN\@ME:PASSWORD@SERVER:PORT
export http_proxy=http://DOMAIN\\USERNAME:P\@SSWORD@SERVER:PORT

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 /etc/environment file:

# echo "http_proxy=http://proxy.example.com:3128/" >> /etc/environment

Set up proxy permanently using /etc/profile.d

For bash and sh users, add the export line given above into a new file called /etc/profile.d/http_proxy.sh file:

# echo "export http_proxy=http://proxy.example.com:3128/" > /etc/profile.d/http_proxy.sh

For csh and tcsh users, use the following command to set the http_proxy variable in a new file called /etc/profile.d/http_proxy.csh file:

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

Replace http_proxy with https_proxy in the export argument to enable proxy over SSL/TLS. This information will be provided by the Network Team who have provided the proxy server related details.

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.

Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

4 thoughts on “How to set up proxy using http_proxy & https_proxy environment variable in Linux?”

Your example “Set up proxy permanently using /etc/environment” should use a double redirect (>>) to APPEND instead of a single redirect (>) to OVERWRITE the environment file. If someone were to copy/paste your example, they would overwrite any other existing environment settings in their /etc/environment file! # echo “http_proxy=http://proxy.example.com:3128/” >> /etc/environment Reply

I would like to set up a proxy in debian10 via environment file.
The username, password, however, includes a comma (,)
How does that affect the phrasing? Reply

Источник

Linux Proxy 101: How to Setup a Proxy Server on Linux

Are you trying to make use of proxies on your Linux-based computer? Then you have to configure it. This article will show you how to set up proxies on Linux to access the Internet.

Linux Proxy Settings

The use of proxies cannot be overemphasized. With a proxy server, you can circumvent geolocationrestrictions, access localized web content, unblock websites, and make use of automation software. All the popular Operating Systems in the market have support for proxies, and Linux is not an exception.

Читайте также:  Will parallels run linux

An overwhelming number of Internet marketers and privacy concerns individuals on the Internet are using Linux-based operating systems. Surprisingly, a good number of them do not know how to configure proxies on their machine. If you’re one of them, you’re on the right page as you are going to be learning about Linux proxy settings here.

When it comes to setting proxies on Linux, you need to know that each distribution of Linux has its own specific configuration method. Not only that, but you also need to be aware that some applications can outrightly disregard your proxy setting and bypass it. Some of the applications would require proxies to set their own way.

Whatever the case may be, make sure you test the proxies and make sure they work before using them for the use case you set them up for. There are many ways of setting proxies on Linux. Some of these methods will be discussed below.

How to Set up Proxies Temporarily on Linux

Set up Proxies on Linux

Not everyone wants to make use of proxies all the time. For some users, the use of proxies has to be ones in a while when the need arises. And after using them for the required use case, they drop them and continue accessing the Internet with their real IP address. To set up proxies temporarily for the current session, you need to do that using the http_proxy & https_proxy environment variable. Launch the terminal and choose one of the options available to you below.

Setting Proxies That Does Not Require Username/Password Authentication

Setting proxies that require no username and password authentication are the easiest in Linux. This is because you only need to specify the server IP and Port. There are two classes of proxies that do not need username and password for authentication.

These are free/public proxies that are considered low quality and proxy servers that provide IP authentication as an alternative. Some providers even have IP authentication as the only means of authentication. For proxies like this, whitelist your device IP from the dashboard the proxy provider provided. After whitelisting the IP address, use the below command for setting the proxies temporarily.

# export http_proxy=http://SERVER:PORT/

Setting Proxies with Username and Password Authentication

YouTube video

When a proxy server requires you to authenticate using a username and password, then you need to modify the command above slightly to accommodate the username and password. Below is the modified code.

Читайте также:  Линукс минт как удалить

If the username and password are correct and you have a valid subscription, then you have set up proxies.

Setting Proxies With Domain

Setting Linux Proxies With Domain

For proxies that require domain details to be setup, run the following modified code.

Handling @ Character in Password

Obviously, you wouldn’t have the @ as a character in your username. However, it commonly used in passwords. Use the below command when your username or password has the @ character.

Look at the code above; you will see a backslash (\) before the @.

How to Set Up Permanent Proxies on Linux

Set Up Permanent Proxies on Linux

If you wouldn’t want to be setting proxies every now and then, then you need to set up proxies using the environment variable. This is done by modifying the file /etc/environment using the code below.

# echo “http_proxy=http://proxy.example.com:3128/” >> /etc/environment

How To Verify Your Proxy Settings

Linux Proxy Settings verification

Linux provides an easy way to check whether you have set up proxies on your machine or not. You will need to use the terminal to check this. Use the commands below. If their values are empty, then your proxies have not been set.

Some times, the above might return values, but your browser isn’t making use of them. Some browsers can decide to overlook your default proxy settings. To check if you’re accessing the Internet using the proxy IP address, visit the WhatIsMyIPAddress website – by click this link. The IP address which you use in accessing the Internet will be displayed. Also, for every software you intend to use, read about the software as some of them tend to disregard the global proxy settings – if that’s the case, you then have to set up proxies in the interface provided by that software.

Linux Proxy Settings command

If you are just concerned about privacy, then a VPN might be a better option. This is because unlike proxies that do not force all applications that access the Internet through them, VPN makes sure all Internet connections go through it. With a VPN set up, you will not have to worry about a particular software disregarding your proxies.

Setting proxies on Linux is actually very easy, especially if you know how to use the terminal – and if you don’t, I advise you to do. With just a few commands, you can get your Linux machine to work with a proxy server. However, do not just configure a proxy and think all your web requests will go through it. You need to confirm if the configuration was successful, and your applications aren’t ignoring it.

Источник

Оцените статью
Adblock
detector