Running Tomcat Behind a Proxy Server
A common deployment scenario involves running Tomcat behind a proxy server. In this kind of environment, the host name and port number that should be returned to the client in the HTTP response should be those specified in the request and not the actual host name and port that Tomcat is running on. These are controlled via the proxyName and proxyPort attributes that we discussed earlier. These attributes affect the values returned for the request.getServerName() and request.getServerPort() Servlet API calls.
Apache can be used as the proxy server. If we use Apache, we can use its proxy module (mod_proxy) to pass on the servlet requests to the Tomcat server:
And on the Tomcat side, the configuration in server.xml for the Coyote HTTP connector:
We could have missed out the proxyName and proxyPort - in which case the response message would have indicated that it came from hostname and 8080 instead of http://www.mydomain.com and port 80.
In the next three chapters we will see how we can use Tomcat connectors to pass requests and responses between Apache and Tomcat.
No comments:
Post a Comment