Pointing Domain Name to IP With Subdirectory

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?

Answer

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.

Attribution
Source : Link , Question Author : ryandlf , Answer Author : webstat

Leave a Comment