Tomcat server root application with apache http proxy on cent os

How to set up tomcat 5 + apache httpd proxy at the root so that will hit my application?

I am running centos and both http and tomcat are running as default sevices.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Are there certain paths/extensions which should go through the proxy? Or every request?

For apache 2.2, you'll need the following modules (check the LoadModule section of your httpd.conf)
- mod_proxy
- mod_proxy_ajp

You can proxy every request to tomcat via [1] in your httpd.conf, while the port of your tomcat server may differ.
ProxyPass / ajp://localhost:8091/
ProxyPassReverse / ajp://localhost:8091/

Open in new window

roychan0328Author Commented:
So I have to move my application to the root of tomcat first, right?

How can I do that?
No, if your application lives in a subfolder, you can specify the folder:
ProxyPass / ajp://localhost:8091/folder/
ProxyPassReverse / ajp://localhost:8091/folder/
ProxyPass /foo ajp://localhost:8091/folder
ProxyPassReverse /foo ajp://localhost:8091/folder
depending upon your needs.

Open in new window

roychan0328Author Commented:
does it work with http proxy instead of ajp?

I tried to do this
ProxyPass / http://localhost:8091/folder/
ProxyPassReverse / http://localhost:8091/folder/

and I got 404

apache httpd redirect me to
Yes, if mod_proxy_http is loaded.

> apache httpd redirect me to

That should not be caused by the ProxyPass directive but by sthg. else.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java App Servers

From novice to tech pro — start learning today.