HTTP Proxy Configuration

If you operate Rancher behind a proxy and you want to access services through the proxy (such as retrieving catalogs), you must provide Rancher information about your proxy. As Rancher is written in Go, it uses the common proxy environment variables as shown below.

Make sure NO_PROXY contains the network addresses, network address ranges and domains that should be excluded from using the proxy.

Environment variablePurpose
HTTP_PROXYProxy address to use when initiating HTTP connection(s)
HTTPS_PROXYProxy address to use when initiating HTTPS connection(s)
NO_PROXYNetwork address(es), network address range(s) and domains to exclude from using the proxy when initiating connection(s)

HTTP Proxy Configuration - 图1Important:

NO_PROXY must be in uppercase to use network range (CIDR) notation.

Docker Installation

Passing environment variables to the Rancher container can be done using -e KEY=VALUE or --env KEY=VALUE. Required values for NO_PROXY in a Docker Installation are:

  • localhost
  • 127.0.0.1
  • 0.0.0.0
  • 10.0.0.0/8
  • cattle-system.svc
  • .svc
  • .cluster.local

The example below is based on a proxy server accessible at http://192.168.0.1:3128, and excluding usage the proxy when accessing network range 192.168.10.0/24 and every hostname under the domain example.com.

  1. docker run -d --restart=unless-stopped \
  2. -p 80:80 -p 443:443 \
  3. -e HTTP_PROXY="http://192.168.10.1:3128" \
  4. -e HTTPS_PROXY="http://192.168.10.1:3128" \
  5. -e NO_PROXY="localhost,127.0.0.1,0.0.0.0,10.0.0.0/8,cattle-system.svc,192.168.10.0/24,.svc,.cluster.local,example.com" \
  6. --privileged \
  7. rancher/rancher:latest

Privileged access is required.

Air-gapped proxy configuration

New in v2.6.4

You can now provision node driver clusters from an air-gapped cluster configured to use a proxy for outbound connections.

In addition to setting the default rules for a proxy server as shown above, you will need to add additional rules, shown below, to provision node driver clusters from a proxied Rancher environment.

You will configure your filepath according to your setup, e.g., /etc/apt/apt.conf.d/proxy.conf:

  1. acl SSL_ports port 22
  2. acl SSL_ports port 2376
  3. acl Safe_ports port 22 # ssh
  4. acl Safe_ports port 2376 # docker port