Explicit Proxy Caching

If you want to use Traffic Server as an explicit proxy cache, you must configure client software (i.e., browsers) to send requests directly to Traffic Server.

If you do not configure Traffic Server to use the transparency option (with which client requests are intercepted en route to origin servers by a switch/router and rerouted to the Traffic Server machine), then clients must configure their web browsers to send HTTP requests to the Traffic Server proxy cache by configuring their browsers to download proxy configuration instructions from a PAC file (Proxy Auto-Configuration file).

Configuring Browsers Manually

To manually configure a browser to send HTTP requests to Traffic Server, clients must provide the following information:

  • The fully-qualified hostname or IP address of the Traffic Server node

  • The Traffic Server proxy server port (by default, 8080)

In addition, clients can specify not to use Traffic Server for certain sites - in such cases, requests to the listed sites go directly to the origin server. The procedures for manual configuration vary among browser versions; refer to specific browser documentation for complete proxy configuration instructions.

By default, Traffic Server answers 404 to a request that matches no remap.config rule. To forward requests for any origin, set proxy.config.url_remap.remap_required to 0, or add map rules for the origins clients may reach. To let browsers reach HTTPS sites, see Allowing HTTPS Through the Proxy.

Allowing HTTPS Through the Proxy

Browsers reach HTTPS sites through a forward proxy with the CONNECT method: the browser asks Traffic Server to open a tunnel to the origin and then runs TLS through it. The default ip_allow.yaml denies inbound CONNECT from every client address except 127.0.0.1 and ::1, so a forward proxy for other clients must allow it.

The recommended way is to allow CONNECT only from your client networks. Add a rule for each network before the 0/0 and ::/0 rules. The rule denies the same methods as the default rules, without CONNECT:

ip_allow:
  - apply: in
    ip_addrs: 192.0.2.0/24
    action: deny
    methods: [ PURGE, PUSH, DELETE, TRACE ]
  - apply: in
    ip_addrs: 2001:db8::/32
    action: deny
    methods: [ PURGE, PUSH, DELETE, TRACE ]
  # ... the default 127.0.0.1, ::1, 0/0 and ::/0 rules follow

If every client that can reach the proxy should be able to tunnel, remove CONNECT from the methods lists of the 0/0 and ::/0 rules instead. That allows CONNECT from any address that can reach the proxy port, so only do it when the port is not reachable from untrusted networks.

Either way, these settings still limit tunnels:

  • proxy.config.http.connect_ports lists the origin ports a tunnel may reach. The default is 443.

  • The default ip_allow.yaml also has an apply: out rule that denies CONNECT to loopback, private and link-local destination addresses.

A denied CONNECT gets a 403 response. Enable the ip_allow debug tag to log which rule denied it. See allowing CONNECT from client networks for how these rules match.

Using a PAC File

A PAC file is a specialized JavaScript function definition that a browser calls to determine how requests are handled. Clients must specify (in their browser settings) the URL from which the PAC file is loaded. You can store a PAC file on Traffic Server (or on any server in your network) and then provide the URL for this file to your clients.

Sample PAC File

The following sample PAC file instructs browsers to connect directly to all hosts without a fully-qualified domain name and to all hosts in the local domain. All other requests go to the Traffic Server named myproxy.company.com.:

function FindProxyForURL(url, host)
{
  if (isPlainHostName(host)) || (localHostOrDomainIs(host, ".company.com")) {
    return "DIRECT";
  }
  else
    return "PROXY myproxy.company.com:8080; DIRECT";
}