Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


I have a website - Registered users will be given the choice of getting a permanent url to their account on as a subdomain like ( or they can opt to have their own domain like So the user can access his/her account through the subdomain URL or their own hostname and the request should be forwarded to a specific url on

For example: or should give the user account from The user should be completely unaware about where the content is coming from.


My website is running as a webapp in tomcat 5.5.28 with apache as the web server. I am using a VPS which means I have control over all the configuration files (apache, tomcat and dns server).

Can you tell me what are the configurations needed to achieve the above scenario??

share|improve this question

A "site" is a bad abstraction for thinking about webserver configuration. You webserver is dealing with 'requests'.

These requests contains 'hostname' and 'url' attributes. You can transform any request attribute with proxy and rewrite rules in apache, but you also need your application to be aware how to deal with transformed parameters.

If you fully control this application - it might be easier to check 'hostname' request header and use it as source data.

share|improve this answer

Not enough info. Depends on what your app does and it's architecure.

One suggestion

Can you use an apache front end with proxy passing or ajp?

Create a virtual host for each domain, different DocumentRoot for each, so stuff like images and skins can be kept separate per domain, different log if you want etc.

I think the configs would be something like this, however I am doing this from memory and don't currently have the facilities to test so use the config suggestion below as a rough idea - it's not a working implementation.

You can replace the proxy passing with proxy_ajp if you have that set up- actually I think proxy_ajp would be a better solution but my memory doesn;t stretch that far.

<VirtualHost *:443>
  DocumentRoot /var/www/
  ErrorLog /var/www/
  LogFormat "%h %l %u %t \"%r\" %>s %b" common
  CustomLog /var/www/
  ProxyPass /yourwebapp
  ProxyPassReverse /yourwebapp
share|improve this answer
Thanks Jason! Yes I am using apache front end with mod_jk (ajp) to route requests to tomcat. Can you tell me what other information you need regarding my application? I want to add domains dynamically, so that I don't have to restart apache every time I add a domain. How can I achieve this? – satish May 10 '10 at 7:03
It's hard to know exactly what to suggest without knowing what your app does and what parts if any change from when a user accesses it from different domains. If its basically a static site then I think the suggestion above will work, but if content changes depending on what domain the user connects to, it may get harder. It will really depend on how your app does what it does and the different behaviour, if any, between accessing it via different domains. – Jason Tan May 10 '10 at 10:37
The content is constant for a particular user. But for user to user, the content changes. Its just that i am giving different access points to the user to access his account on my site. My application is a java/jsp app, which fetches content from the mysql database depending on the userid and serves the content. Whether the request comes through or or my application treats the request as and fetches the content accordingly. Its just like if allows the groups to have their own domains. – satish May 10 '10 at 13:49

Your Answer


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.