How do I redirect from Apache to Tomcat?

早过忘川 提交于 2019-11-28 03:12:14

The correct way to do things is to leave Apache at 80 and Tomcat at 8080 and use a plug in (preferably mod_proxy) to proxy Tomcat from Apache. mod_proxy would only take you 10 minutes to set up.

This how-to is very simple to follow.

The usual way this is done, as you already mentioned, is to use mod_jk from Apache HTTPD to forward that content that you want to be processed by Tomcat.

There is a Quick HowTo at tomcat.apache.org. You need to do the following:

  • Copy mod_jk.so into the appropriate modules directory for Apache HTTPD.
  • Create a configuration file workers.properties
  • In Apache HTTPD's httpd.conf, add a section to configure mod_jk.
  • Ensure that Tomcat is configured to accept the mod_jk protocol, which is usually on port 8009.

The lines in httpd.conf with JkMount:

JkMount  /examples/* worker1

tell Apache HTTPD which requests are to be forwarded to Tomcat.

gareth_bowles

Both the helpful answers above are good, but I much prefer mod_proxy over mod_jk. There's no extra installation to do for mod_proxy, unlike mod_jk, and the setup is much easier. mod_jk gives you more control over detailed tuning of Tomcat parameters, but if you just want a simple redirect from Apache to Tomcat, mod_proxy is the way to go.

If you want static content to be served by Apache instead of Tomcat you should use mod_jk : http://tomcat.apache.org/tomcat-6.0-doc/proxy-howto.html

And what about SSL - if we want Apache to handle HTTPS, because it is faster then java/Tomcat?

you should configure your tomcat using this link. for tomcat 7 http://tomcat.apache.org/tomcat-7.0-doc/proxy-howto.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!