Using standard configurations of Tomcat, web applications can ask for the server name and port number to which the request was directed for processing. When Tomcat is running standalone with the HTTP/1.1 Connector, it will generally report the server name specified in the request, and the port number on which the Connector is listening. The servlet API calls of interest, for this purpose, are:
ServletRequest.getServerName(): Returns the host name of the server to which the request was sent.
ServletRequest.getServerPort(): Returns the host name of the server to which the request was sent.
ServletRequest.getLocalName(): Returns the host name of the Internet Protocol (IP) interface on which the request was received.
ServletRequest.getLocalPort(): Returns the Internet Protocol (IP) port number of the interface on which the request was received.
When you are running behind a proxy server (or a web server that is configured to behave like a proxy server), you will sometimes prefer to manage the values returned by these calls. In particular, you will generally want the port number to reflect that specified in the original request, not the one on which the Connector itself is listening. You can use the proxyName and proxyPort attributes on the <Connector> element to configure these values.
Proxy support can take many forms. The following sections describe proxy configurations for several common cases.