How to add proxy exceptions on Ubuntu desktop

Last updated on October 7, 2020 by Dan Nanni

Question: My Ubuntu desktop computer is connected behind a corporate proxy. I configured necessary proxy setting on Ubuntu desktop, so all my HTTP/HTTPS traffic goes through the corporate proxy. However, I need to be able to selectively bypass the proxy for some websites (e.g., websites with corporate IP addresses or private IP addresses). On "network proxy" settings on Ubuntu desktop, I cannot find where to define proxy exceptions. How can I configure proxy exceptions on Ubuntu desktop?

When you are using a proxy, the "proxy exception list" (also known as "ignore-hosts list") is sometimes necessary. The proxy exception list basically tells an application or desktop (which uses a proxy) to not use the proxy for particular destinations or websites. The proxy exceptions are needed when you are trying to access web servers on local LAN or those with private IP addresses which are not reachable from outside. You need to directly connect to those web servers, not through the proxy.

Some applications (e.g., Firefox) come with their own in-app proxy settings. In this case, you can use the app-specific proxy settings to define proxy exceptions.

If you want to rely on the system-wide proxy settings of Ubuntu desktop, you can configure proxy exceptions as follows. Note that if you are looking to set up proxy exceptions in a headless server environment, refer to this tutorial instead.

Add Proxy Exceptions from the Command-Line

On GNOME-based Ubuntu desktop, you can use the gsettings command to adjust proxy settings from the command line, and that includes proxy exceptions.

Type the following command, and it will print the current proxy exception list (or "ignore-hosts" list) of your desktop.

$ gsettings get org.gnome.system.proxy ignore-hosts
['localhost', '127.0.0.0/8', '::1']

The default proxy exception list contains three local hostname and addresses. 127.0.0.0/8 is an address block resolved for loopback, and ::1 is the IPv6 loopback address.

To change proxy exceptions, use set option with gsettings command as follows.

$ gsettings set org.gnome.system.proxy ignore-hosts "['localhost', '127.0.0.0/8', '192.168.1.0/24', 'xmodulo.com', '::1']"

Permitted items in the proxy exception list are hostnames (e.g., www.cnn.com), domains with wildcard (e.g., *.xmodulo.com), IPv4/IPv6 addresses, or CIDR blocks (e.g., 192.168.1.0/24).

Now verify that the proxy exception list is successfully modified.

$ gsettings get org.gnome.system.proxy ignore-hosts
['localhost', '127.0.0.0/8', '192.168.1.0/24', 'xmodulo.com', '::1']

The desktop settings modified by gsettings are preserved across desktop reboots.

Add Proxy Exceptions via GUI

The graphical counterpart for gsettings command-line tool is dconf-editor.

First install it on your desktop.

$ sudo apt-get install dconf-editor

To configure proxy exceptions, launch dconf-editor and go to system"->"proxy on the left side bar.

Then on the right-side pane, modify ignore-hosts field.

Similar to gsettings, any change made with dconf-editor remain permanent across system reboots.

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal (Credit Card) or Bitcoin (1M161JGAkz3oaHNvTiPFjNYkeABox8rb4g).

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean