Apache subdomain redirect into Tomcat

apachemod-jkmod-proxysubdomaintomcat

I'm pretty new to Apache HTTP, and sysadmin-ing in general, so i have this question
I have a domain (www.doamin.com) with an Apache listening to port 80,
also I have an Apache Tomcat on the same domain configured to port 8080.

Is there a way to configure a subdomain (i.e, tomcat.domain.com)
so it will redirect into my tomcat specific application,
so user can access applications through app1.domain.com and app2.domain.com (and it will be served by Tomcat)?

I've seen a lot of mentioning to

mod_jk

and

mod_proxy

but all of the post assumed prior knowledge with Apache.
can someone walk me thorugh?

Many thanks, -PK.

Best Answer

mod_jk is outdated. It is recomended to use mod_proxy (mod_proxy_http or mod_proxy_ajp) to connect forward requests to your apache server to the tomcat.

  1. define a virtual host in your apache config
  2. create a proxy directive that forwards your requests to tomcat

Maybe this SO question give you some hints.

You can define two virtual hosts (app1.domain.tld and app2.domain.tld) that have proxy definitions for their designated apps. Example for app1:

<VirtualHost *:80>
    ServerName app1.domain.tld
    ProxyRequests Off
    ProxyPreserveHost On
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    ProxyPass / http://localhost:8080/app1
    ProxyPassReverse / http://localhost:8080/app1
</VirtualHost> 
Related Topic