Class AbstractProxyServlet

java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.eclipse.jetty.proxy.AbstractProxyServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
AsyncMiddleManServlet, ProxyServlet

public abstract class AbstractProxyServlet extends javax.servlet.http.HttpServlet

Abstract base class for proxy servlets.

Forwards requests to another server either as a standard web reverse proxy or as a transparent reverse proxy (as defined by RFC 7230).

To facilitate JMX monitoring, the HttpClient instance is set as ServletContext attribute, prefixed with this servlet's name and exposed by the mechanism provided by ServletContext.setAttribute(String, Object).

The following init parameters may be used to configure the servlet:

  • preserveHost - the host header specified by the client is forwarded to the server
  • hostHeader - forces the host header to a particular value
  • viaHost - the name to use in the Via header: Via: http/1.1 <viaHost>
  • whiteList - comma-separated list of allowed proxy hosts
  • blackList - comma-separated list of forbidden proxy hosts

In addition, see createHttpClient() for init parameters used to configure the HttpClient instance.

NOTE: By default the Host header sent to the server by this proxy servlet is the server's host name. However, this breaks redirects. Set preserveHost to true to make redirects working, although this may break server's virtual host selection.

The default behavior of not preserving the Host header mimics the default behavior of Apache httpd and Nginx, which both have a way to be configured to preserve the Host header.

See Also: