You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Tonhofer <el...@m-plify.net> on 2008/04/02 19:31:29 UTC

Tomcat and "virtual host" routing behind a Proxy

Hi there,

A question about Tomcat "virtual host" routing behind a reverse proxy.
I have worked on this for a couple of hours and looks as if Tomcat does 
the unexpected (sale bĂȘte!)

Here's the idea:

I am (reverse) proxing requests from Apache to a Tomcat instance running 
on localhost.
I also have several virtual hosts on the same machine and I want to have 
Tomcat reflect this virtual host setup
(i.e. a separate appBase for each virtual host)

Proxing is done using HTTP, instead of AJP, with request for

"firsthost.com" directed to "127.0.0.1:9330"

and

"secondhost.com" directed to "127.0.0.1:9331"

I though that if I did this on the Tomcat side:

  <Service name="standalone_service">
        <Connector port="9330" address="127.0.0.1" 
proxyName="firsthost.com" proxyPort="80" />
        <Connector port="9331" address="127.0.0.1" 
proxyName="secondhost.com" proxyPort="80" />
        <Engine name="standalone_engine" defaultHost="default_host">
            <Host name="default_host">
                   ... </Host>
            <Host name="firsthost.com">
                   ... </Host>
            <Host name="secondhost.com">
                   ... </Host>
       </Engine>
  </Service>

.....then requests for "firsthost.com", caught by the HTTP connector on 
port 9330, would be routed to the "host" named by
proxyName="firsthost.com". Similarly requests for "secondhost.com", 
caught by the HTTP connector on port 9331, would
be routed to the "host" named by proxyName="secondhost.com".

Well, actually no. The request go to go to "default_host" in all cases.

So... does the "proxyName" attribute have no influence on routing by 
hostname? Is this expected behaviour? Can anyone confirm/disconfirm this?

As a workaround I could create several "Services", each with its own 
"Connector" on a separate port, but still...

Best regards,

-- David




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org