35
Chapter 5
Reverse Proxy and HTTP Redirects
HTTP Reverse Proxy
In forward proxy caching, Traffic Server acts as a proxy server and receives proxy requests. In reverse proxy
caching, because Traffic Server is advertised as the origin server, Traffic Server needs to act as an origin server
rather than a proxy server, meaning that it receives server requests, not proxy requests. To satisfy proxy
requests, Traffic Server must construct a proxy request from the server request.
In HTTP, server requests differ from proxy requests. The main difference is that server requests do not specify
the entire URL, just the path. A server request might look like this:
GET /index.html HTTP/1.0
HOST: real.janes_books.com
Whereas the corresponding proxy request would look like this:
GET http://real.janes_books.com/index.html HTTP/1.0
HOST: real.janes_books.com
Traffic Server can construct a proxy request from a server request by using the server information in the host
header.
However, the correct proxy request must contain the hostname of the origin server, not the advertised
hostname that the name servers associate to Traffic Server. The advertised hostname is the name that appears
in the host header. For example, for the origin server
real.janes_books.com
in Figure 5-1‚ on page 34, the
server request and host header would be:
GET /index.html HTTP/1.0
HOST: www.janes_books.com
And the correct proxy request should be:
GET http://real.janes_books.com/index.html HTTP/1.0
HOST: real.janes_books.com
To translate
www.janes_books.com
to
real.janes_books.com
Traffic Server needs a set of URL
rewriting rules (mapping rules). Mapping rules are described in
Using mapping rules‚ on page 36
.
Generally, you use reverse proxy mode to support more than one origin server. In this case, all of the advertised
hostnames resolve to the IP address or virtual IP address of Traffic Server. Using host headers, Traffic Server
is able to translate server requests for any number of servers into proxy requests for those servers.
If Traffic Server receives requests from older browsers that do not support host headers, Traffic Server can
route these requests directly to a specific server, or send the browser to a URL containing information about
the problem. Refer to
Setting HTTP reverse proxy options‚ on page 38
.
Handling origin server redirect responses
Origin servers often send redirect responses (redirects) back to browsers redirecting them to different pages.
For example, if an origin server is overloaded, it might redirect browsers to a less loaded server. Origin servers
also redirect when web pages have moved to different locations. When Traffic Server is configured as a
reverse proxy, it must readdress redirects from origin servers so that browsers are redirected to Traffic Server,
not to another origin server.
To readdress redirects, Traffic Server uses reverse-map rules. In general, you should set up a reverse-map rule
for each map rule. To create reverse-map rules, refer to “Using mapping rules,” below.