0

Specifically I am using Apache 2 and redirecting port 80 to a Tomcat installation. Within tomcat I can setup multiple applications and they are referenced as so:

http://11.111.111.1/Test1

http://111.11.111.1/Test2

I have one static IP and i'd like to be able to host multiple sites on either tomcat or apache depending on the app architecture but how do I point my domain name to my static ip and the websites specific subdirectory? I am using domain.com to manage my domains and it seems I can only point to an ip address (no adding of a subdirectory allowed).

Should I be using virtual hosts as described here: apache rewrite to assign folders to domains

Does that somehow determine the calling domain name and route it to the correct directory regardless of the fact that the same ip is using on multiple domain names?

2 Answers 2

0

Yes you can have many tomcat and/or apache sites in a single IP

Here are the steps involved in doing the above:

For tomcat sites:

  1. Deploy the app in a tomcat port like 8080 or 9090 etc
  2. Install apache webserver. Install and configure apache JK connector through mod_jk so that apache webserver can talk to tomcat app server
  3. For apache-tomcat jk connector, configure workers through workers.properties file in apache conf directory. 1 worker configuration is a must for each tomcat application. So if you have 3 tomcat sites, you need 3 workers each listening on specific port.
  4. Create apache virtual hosts config (by changing httpd.conf file) and configure port 80 and 443(if ssl). If you have 4 tomcat sites you need 4 virtual hosts for example. In each of these virtual hosts, you have to specify its corresponding worker

That should be it

========== If it is a pure apache web portal without tomcat, step 4 above is enough.

0

Your "domain" can only "point" to an IP address. Web browsers connect to that address then send the request URL. Normally no path is used to get the main front page. To get a browser to go to a specific path, the URL with that path is used.

Merely running multiple (non-HTTPS) web sites on one IP address is easy with most web server software. The host name is transmitted with the HTTP request (except in very old HTTP/1.0 usage) and the web server sorts that out with its VirtualHost configuration (or equivalent configuration methods). Is there a reason you can't use that? Not everyone knows that is going on, so I can see how one might think they need separate IPs or other tricks.

FYI, for secure web over HTTPS, you do need separate IPs (or for separate host names within the same domain name, a wild card SSL certificate), or in cases of being redirected to an HTTPS URL, separate port numbers are doable.

2
  • The reason i'm not using your suggestion is because this is all pretty new to me and honestly I didn't know the proper protocol. Thank you for pointing me in the right direction. Does the link I provided in my OP explain what you are suggesting? If not, would you happen to have a resource that might help guide me along...a tutorial or something? Thanks again.
    – ryandlf
    Aug 21, 2012 at 17:02
  • That link looks like a valid way to do it. I have not tried it that way, so I do not know for sure.
    – Skaperen
    Aug 22, 2012 at 0:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.