Skip to content

Proxy Configuration Issues

Ladislav Slezák edited this page Apr 6, 2016 · 1 revision

Proxy Configuration Issues

We found out that the network proxy configuration is handled a bit differently in Ruby than by other tools.

Usually you define the HTTP proxy via http_proxy (or HTTP_PROXY) environment variable. The white list of the hosts (or domains) which should be always connected directly without the proxy is defined in the no_proxy variable.

The usual value looks like localhost, 127.0.0.1, foo.bar.com, .example.com. The first two values disable proxy for the loopback device, the next one for the foo.bar.com host and the last one for all hosts in the example.com domain.

However, Ruby by default treats the no_proxy value a bit differently.

Handling Proxy Exceptions in Ruby

There are some differences how Ruby handles the no_proxy value:

  • Ruby does not ignore spaces around the values, with the example above it would skip proxy for the ␣foo.bar.com host but use it for foo.bar.com. This is completely unexpected behavior.

  • Ruby does not treat values starting with a dot as domain names. Instead it tries to match all values as both host name and domain name.

    That means the .example.com does not work as expected - host name and domain names cannot contain dots so this will actually never match.

Workaround

There are some rules how to set no_proxy to workaround the issue:

  • Do not use spaces.

  • Specify domains without the leading dot.

Regarding the dots - to be sure that the no_proxy value works in Ruby and also with the other tools then for domains you should use both versions - with a leading dot and without it.

So instead of the localhost, 127.0.0.1, foo.bar.com, .example.com example above you should use localhost,127.0.0.1,foo.bar.com,.example.com,example.com.