Bug 51269

Summary: Enhancement: Allow Alias to support wildcards
Product: Tomcat 5 Reporter: xandrewrampulla
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P2    
Version: Unknown   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description xandrewrampulla 2011-05-26 12:59:43 UTC
I would like my tomcat instance to be able to respond to multiple DNS subdomains without having to explicitly specify those subdomains.  For example I would like to be able to create an alias that looks like

         <Host name="myapp" >
            <Alias>*.myapp.mycompany.com</Alias>
         </Host>

With this configuration, the server should respond properly to 
a.b.c.myapp.mycompany.com
b.c.d.myapp.mycompany.com
c.d.e.myapp.mycompany.com
etc.

This seems like it could be done easily by changing org.apache.catalina.connector.MapperListener:registerEngine so that instead of 
    if (aliases[i].equalsIgnoreCase(defaultHost)){
        isRegisteredWithAlias = true;
        break;
    }
we instead did something like
    if(Pattern.matches(alias[i].toLowerCase().replaceAll("\\*", ".*?"), defaultHost.toLowerCase())) {
        isRegisteredWithAlias = true;
        break;
    }
Comment 1 Mark Thomas 2011-05-26 13:03:57 UTC

*** This bug has been marked as a duplicate of bug 18500 ***