logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Apache & Tomcat
Author
Xenobius



Joined: 13 Jul 2013
Posts: 2
Location: Malta

PostPosted: Sat 13 Jul '13 14:33    Post subject: Apache & Tomcat Reply with quote

Hi all, I am new here and I would like to thank you for your time reading my query.

Problem: I host my online shop with a private hosting company and it is becoming expensive. Now I decided to host everything on my personal server. I have 2 websites.

I was told that if my shop contains lots of images and other static content, it would make sense to use Apache and integrate it with Tomcat and so I did using this guide. http://www.ntu.edu.sg/home/ehchua/programming/howto/ApachePlusTomcat_HowTo.html

Questions:
1. Apache is running on port 80 while Tomcat is running port 8080. Should Apache be the one accepting requests? (only port 80 will be accessible from outside)

2. I put a simple jsp file in Tomcat and accessed it from Apache and it worked. Is this the way to go? If so how will Apache know when to send out static content? I mean I intend to have lots of images... if they are in Tomcat, how will Apache serve them quickly?

3. If I have 2 websites with the aim of hosting them on a single IP, where should I do this configuration? Apache, Tomcat or both?

I would be very grateful if you could remove all these doubts so that I can continue searching and learning the right way.

Thanks
X
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Tue 16 Jul '13 16:17    Post subject: Re: Apache & Tomcat Reply with quote

Xenobius wrote:

Questions:
1. Apache is running on port 80 while Tomcat is running port 8080. Should Apache be the one accepting requests? (only port 80 will be accessible from outside)


Yes

Xenobius wrote:

2. I put a simple jsp file in Tomcat and accessed it from Apache and it worked. Is this the way to go? If so how will Apache know when to send out static content? I mean I intend to have lots of images... if they are in Tomcat, how will Apache serve them quickly?


You should exclude the path of the static content to your rewriting / mod_jk proxying.

Xenobius wrote:

3. If I have 2 websites with the aim of hosting them on a single IP, where should I do this configuration? Apache, Tomcat or both?


You can use a single IP if you use v(irtual)hosts
Back to top
Xenobius



Joined: 13 Jul 2013
Posts: 2
Location: Malta

PostPosted: Tue 16 Jul '13 22:44    Post subject: Reply with quote

Thanks for your reply. Could you kindly:

2. Explain how please?

Oh and I managed to use VHosts in apache and in Tomcat and I managed to get through to 2 websites from one IP.

Thanks a lot
X
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Thu 18 Jul '13 10:10    Post subject: Reply with quote

As it is for httpd apache you can use name based vhosts see http://httpd.apache.org/docs/current/vhosts/name-based.html There are also tons of vhost (virtual hosts) configurations in the forum.

In the name based vhost of apache you can run a reverse proxy to each vhost of your tomcat.

Here is an example vhost how I connect via ajp to my jenkins server https://mariobrandt.de/archives/apache/apache-ajp-reverse-proxy-322/

For the name based vhost for tomcat you have to google a bit, cause I have no experience with that so far.
Back to top


Reply to topic   Topic: Apache & Tomcat View previous topic :: View next topic
Post new topic   Forum Index -> Apache