tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Ward <>
Subject HttpConnector: seting proxyName dynamically
Date Wed, 11 Aug 2004 20:22:37 GMT
Hello -- I'm trying to setup Apache 2.0.50 and Tomcat 4.1.30 together,
with requests relayed from Apache to Tomcat using mod_proxy.  (We've
been using mod_jk for many months, but have observed random,
hard-to-reproduce flakiness, so I'm investigating the possibility of
dropping mod_jk in favour of mod_proxy.)

Everything works fine as long as I set proxyName and proxyPort in the
<Connector> element, eg.:

    <Connector className="org.apache.catalina.connector.http.HttpConnector"
               address="" port="8180"
               proxyName="servername" proxyPort="80"
               minProcessors="1" maxProcessors="5"
               acceptCount="5" debug="0" connectionTimeout="30000"/>

(Without those, redirects didn't work: a request for "/foo" should have
been redirected to "http://servername.domain/foo/", but was actually
redirected to "http://localhost:8180/foo/", because Tomcat had no clue
what hostname was used by the outside world.)

No problem, right?  Well, there is: we install Apache and Tomcat on
hundreds of servers at dozens of customer sites, and manually editing
server.xml to set the server hostname every time we setup or upgrade a
server is not an option.

For Apache, we have this line in httpd.conf:

  Include conf/servername.conf

and create servername.conf at installation time like this:

  echo "ServerName" `hostname` > conf/servername.conf

This works like a charm, at least until the server changes names.  ;-)

So I'd like to cook up something like this for Tomcat.  I suppose I
could hold my nose and install a default server.xml that looks like

    <Connector className="org.apache.catalina.connector.http.HttpConnector"
               address="" port="8180"
               proxyName="@SERVERNAME@" proxyPort="80"
               minProcessors="1" maxProcessors="5"
               acceptCount="5" debug="0" connectionTimeout="30000"/>

and then do some sed magic at installation time, but, well, blecchhhh.
Surely there's a better way!



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message