How to configure HTTP proxy exceptions on Linux

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Hello, friends. In this post, you will learn How to configure HTTP proxy exceptions on Linux. This post, although simple to execute, can be quite useful when working with proxy.

Introduction

A proxy is a tool known to provide anonymity on the Internet by hiding the user’s public IP address. One of the easiest ways to understand the concept is to consider it to be an intermediary between your computer and the Internet.

One of the main reasons for using a proxy is to prohibit access to certain content. This is useful in corporate or even parental environments. Another reason is to control access and the way the internet is accessed such as usage times, content or filtered protocols.

Understanding the concept of proxy, it is possible that the need may arise to bypass the proxy for certain cases and specific addresses. This for any purpose, but the most common is to test outside the proxy.

Let’s go for it.

Configure HTTP proxy exceptions on Linux

In the specific case of Linux, there is the http_proxy variable that defines the proxy server, although of course you can always define them from the graphical interface. However, there is also the variable no_proxy which is where the exceptions are defined.

If you want the changes to be temporary then, just open a terminal and run

export no_proxy="127.0.0.1, localhost, gmail.com

Of course, I have used an example where 127.0.01, localhost and gmail.com are defined as exceptions but for the rest of the hosts the proxy will be used. That is to say, on these hosts, the HTTP request will be made directly without passing through the proxy.

If you want to make it permanent and even more global on the system, then you will have to do some extra steps, and it depends on your Linux distribution.

For Debian, Ubuntu and derivatives such as Linux Mint

sudo nano /etc/environment

And inside the file, add something like this

http_proxy="http://your-proxy:[port]"
no_proxy="[hosts]"

For example,

http_proxy="http://my-proxy.com:1000"
no_proxy="127.0.0.1, localhost, gmail.com"

Save the changes and close the editor.

RHEL, Alma Linux, Fedora, Rocky Linux and so on

For the RHEL family, the procedure is similar, although the file to edit or create is different.

sudo vim /etc/profile.d/proxy.sh

And there, add the same as in the case of Debian and the family.

http_proxy="http://my-proxy.com:1000"
no_proxy="127.0.0.1, localhost, gmail.com"

Save the changes and you are done.

Conclusion

Proxy servers are very useful for security and controlled use situations, but you can always make an exception to the rule and add hosts that do not use it.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook