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

I have question. Let's assume that I have API which allows me to add dynamically add DNS records. Now, I would like to run simple application on Tomcat and put Apache in front of it, so that any domain added to DNS pointing on this Apache would be served by application running. I read a bit about Dynamically Configured Mass Virtual Hosting on http://httpd.apache.org/docs/2.0/vhosts/mass.html but this seams would work when domains would point to some directory, when usually I was using mod_jk to use Apache and Tomcat together. So my other finding was mod_proxy but how to tell apache simply to serve any domain on web app?

Please forgive me if I am asking about something obvious for administration gurus, but I do not have to much experience with this subject.

Thanks in advance!

Konrad

share|improve this question

2 Answers 2

up vote 0 down vote accepted

If I understand you correctly, it's simple - the first virtual host listed in the Apache config traps any unknown domain name by the server. So all you need to do is enable name-based virtual hosts and define only one default vhost that jkmounts your Tomcat webapp. I prefer using mod_jk for Apache <=> Tomcat.

NameVirtualHost *:80

LoadModule jk_module /usr/local/lib/mod_jk.so
JkShmFile      /var/log/httpd/mod_jk.shm
JkLogFile      /var/log/httpd/mod_jk.log
JkLogLevel     error

<VirtualHost *:80>
 ...other options ...
 JkMount /* ajp13
</VirtualHost>

That's the basic setup, see here for more.

share|improve this answer
    
Hi, I will give it a try. Sounds like exactly what I need! Thanks! –  Konrad Jul 12 '10 at 6:57

I have no experience with tomcat, but using apache hooks you can build a module that intercepts the request processing phase, and do a redirect depending on the "hostname" attribute. Hope it helps.

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.