Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have One Staic IP on one Server which is publically accessible over the Internet. I am running an Apache WebServer on that Server.

How can I make - 3 Web Applications (On Tomcat) running on 3 different intranet PC's - available over the Internet - using the one Publically accessible IP that I have?.

It should be noted that the Static-IP Server Machine can has two network adapters and can definitely access the intranet PC's too.

Please advise the best method to solve this problem. Thanks much.

share|improve this question

migrated from stackoverflow.com Nov 19 '09 at 14:43

This question came from our site for professional and enthusiast programmers.

3 Answers 3

My tomcat virtual hosts settings:

first enable mod_jk for apache:

a2enmod mod_jk

then restart apache

cat /etc/apache2/sites-enabled/tomcat:

NameVirtualHost *:80

    <VirtualHost *:80>
 DocumentRoot /usr/share/tomcat5.5/webapps/mydomain1.com
 ServerName mydomain1.com
 JkMount /* mydomain1
 ErrorLog /usr/share/tomcat5.5/logs/mydomain1.com-error_log
 CustomLog "|/usr/sbin/rotatelogs -l /usr/share/tomcat5.5/logs/mydomain1.com-access-%Y-%m-%d.log 86400" combined
</VirtualHost>

<VirtualHost *:80>
 DocumentRoot /usr/share/tomcat5.5/webapps/mydomain2.com
 ServerName mydomain2.com
 JkMount /* mydomain2
 ErrorLog /usr/share/tomcat5.5/logs/mydomain2.com-error_log
 CustomLog "|/usr/sbin/rotatelogs -l /usr/share/tomcat5.5/logs/mydomain2.com-access-%Y-%m-%d.log 86400" combined
</VirtualHost>

cat /etc/apache2/workers.properties

workers.tomcat_home=/usr/share/tomcat5.5/
workers.java_home=/usr/lib/jvm/java-6-sun
ps=/
worker.list=mydomain1, mydomain2

worker.lic.type=ajp13
worker.lic.host=mydomain1.com
worker.lic.port=8009
worker.lic.lbfactor=1

worker.wideok.type=ajp13
worker.wideok.host=mydomain2.com
worker.wideok.port=8009
worker.wideok.lbfactor=1

cat /usr/share/tomcat5.5/conf/server.xml

<Server port="8005" shutdown="SHUTDOWN">

  <Listener className="org.apache.catalina.core.AprLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
  <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
  <GlobalNamingResources>
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
    <Resource name="UserDatabase" auth="Container"
        type="org.apache.catalina.UserDatabase"
        description="User database that can be updated and saved"
        factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
        pathname="conf/tomcat-users.xml" />

  </GlobalNamingResources>
  <Service name="Catalina">

    <Connector port="8080" maxHttpHeaderSize="8192"
               maxThreads="150000" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="3600000" disableUploadTimeout="true" />


    <Connector port="8443" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" disableUploadTimeout="true"
               acceptCount="100" scheme="https" secure="true"
               clientAuth="false" SSLEnabled="true"
               keystoreFile="/usr/share/tomcat5.5/webapps/somedomain.com/ROOT/WEB-INF/ssl/sms_ssl.key" keystorePass="changeit"
            sslProtocol="SSL" />

 <Connector port="8009" 
     enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />

<Engine name="Catalina" defaultHost="localhost">
 <Listener className="org.apache.jk.config.ApacheConfig"
    modJk="/usr/lib/apache2/modules/mod_jk.so"
    workersConfig="/etc/apache2/workers.properties"/>

<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

 <Host name="localhost" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
 </Host>

 <Host name="mydomain1.com"
    appBase="/usr/share/tomcat5.5/webapps/mydomain1.com"
    unpackWARs="true"
    autoDeploy="true"
    xmlValidation="false"
    xmlNamespaceAware="false">
 </Host>

 <Host name="mydomain2.com"
    appBase="/usr/share/tomcat5.5/webapps/mydomain2.com"
    unpackWARs="true"
    autoDeploy="true"
    xmlValidation="false"
    xmlNamespaceAware="false">
 </Host>

</Engine></Service></Server>

and dir structure for /usr/share/tomcat5.5/webapps

/usr/share/tomcat5.5/webapps/
                             ROOT/WEB-INF
                             ROOT/index.jsp

/usr/share/tomcat5.5/webapps/mydomain1.com/
                                          ROOT/WEB-INF
                                          ROOT/index.jsp

/usr/share/tomcat5.5/webapps/mydomain2.com/
                                          ROOT/WEB-INF
                                          ROOT/index.jsp

Hope that helps :)

share|improve this answer

If you use mod_jk or mod_proxy to connect Apache httpd and Tomcat, this is very easy to do.

First, you assign a path for each Tomcat, like

  http://example.com/app1
  http://example.com/app2

Use mod_jk as example, you need to setup workers for each Tomcat (worker1, worker2) and just redirect the request to the corresponding worker like this,

  JkMount  /app1/* worker1
  JkMount  /app2/* worker1

If you don't want to assign path for some reason, you need to get multiple domain names, one for each Tomcat and use mod_rewrite to inject the path internally based on HTTP_HOST header value.

share|improve this answer

Check here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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