aspose file tools*
The moose likes Tomcat and the fly likes Wild Card Sub Domains Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Wild Card Sub Domains" Watch "Wild Card Sub Domains" New topic
Author

Wild Card Sub Domains

Louis Bros
Ranch Hand

Joined: Jun 03, 2011
Posts: 54

Hi all,

I'm trying to set up a wildcard sub domain where

*.domain.com maps to www.domain.com/sub

Currently my server.xml looks like this


I've seen an example of what I want to do where

Is placed within the sub domain host element. I've read however that, that can cause problems and that context elements should be kept out of the server.xml and instead be defined in the context.xml.

Right now both the sub domain and the domain will map to the ROOT folder. So at this stage I think I could use a filter to forward according to the sub domain or I could do something to the context.xml.

Could someone please suggest the correct way of implementing this and if I need to use the context.xml what should the context element look like?

Thanks, Louis


OCA7
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

You're talking about 2 different animals here.

Actually, "*.domain.com" wouldn't represent wildcard sub-domains, it would represent wildcard hostnames. A fully-qualified domain name (FQDN) includes the hostname as its first element. A true wildcard subdomain name would be "*.*.domain.com" or "www.*.domain.com". The domain name can never be a wildcard.

In order to implement such a scheme, however, you'd need a specialized Domain Name Server setup for your authoritative name servers. DNS is basically supposed to be a "telephone directory" where, given a FQDN, the directory is consulted, and (assuming a match), a corresponding IP address is returned. What you'd need would be a DNS server that - instead of serving as a database - cooked up IP addresses on the fly. Which wouldn't be that hard if you only have one server, but I happen to have more than physical host on my domain, so the logic would be more complicated than just "match anything/return same thing" in my case.

You also probably won't make many friends using this scheme, since for performance reasons, DNS entried are usually cached at various levels between client and server, and caching and dynamic DNS are somewhat opposed.

The second part of your question can be resolved in several ways. One way is to front Tomcat with a server that can translate URLs such as Apache. Another way is to deploy your webapp at the context root for the Tomcat Host.


Customer surveys are for companies who didn't pay proper attention to begin with.
Louis Bros
Ranch Hand

Joined: Jun 03, 2011
Posts: 54

Thanks very much for the explanation, I better read up
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Wild Card Sub Domains