Tomcat CatchAll (Hosts)

Re: Several hosts within one tomcat / catch-all problem 2010-11-21 20:08

Hi Konstantin,
>BTW, you can put those names in an external file and use it in the
>server.xml as an XML entity. Like the example in
>http://wiki.apache.org/tomcat/FAQ/Password
Inspired by this thread and having a similar issue in maintaining virtual host aliases I edited my server.xml as follows:
I added this before the <Server>.
<!DOCTYPE aliases-xml [
<!ENTITY aliases SYSTEM "/path/to/network/storage/aliases.txt">
]>
I moved my <Alias> tags to /path/to/network/storage/aliases.txt, substituting &aliases;
This works very well. Thanks!
>and use JMX or call mapper.addHostAlias(..) directly to add aliases
>programmatically at runtime. (though there is no guarantee that the
>Mapper API does not change between Tomcat minor releases).
I investigated what an implementation of this might look like at a higher level. In looking through the Tomcat interfaces it looks like this is similar to the notion of automatically creating Context for users with a UserConfig listener.
It would be an AliasConfig class extending HostConfig.
<Listener className="my.web.server.listener.package.AliasConfig" aliases="/path/to/alias/file"/>
Then in the start event function it is as simple as "host.addAlias(subDomainName);" for each alias found in the aliases file.
Does this make sense?
Regards,
Dave


Tag Cloud