Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Wild Card Sub Domains

 
Ranch Hand
Posts: 54
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Saloon Keeper
Posts: 25608
183
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Louis Bros
Ranch Hand
Posts: 54
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks very much for the explanation, I better read up
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic