You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jeremy <je...@paribus.com> on 2007/01/09 17:01:02 UTC

Using the balancer app to redirect. Well, trying to

Hi

Sorry if this is a bit of a dumb question, but I just wondered if anyone 
had any handy hints for the problem below:

I'm trying to set up a tomcat 5.0.28 instance (on Debian)  to achieve 
redirecting accesses to site1.company.com through to newsite1.org, using 
the balancer app. rather than apache webserver and the AJP connectors.

The easiest solution would of course be just to set up a DNS level 
redirect on all port-80 accesses by putting in an A-name record to point 
at newsite1.org, but the problem is that newsite1.org doesn't have a 
direct IP, and you can't put the alphanumeric address in the DNS.

THe canonical way of doing it appears to be to set up apache webserver 
as a front-end to tomcat and manage it using webapp connectors like AJP, 
but apart from being a total pain to organise (and memory-hungry in my 
setup as well), that introduces the webapp connectors, which have caused 
problems with the applications I am running in the past.

Sooo.. what I have tried to do instead is be sneaky, and set up an 
instance of the tomcat balancer app on the server (by copying the 
balancer app instance in tomcat/webapps/ and slightly modifying the 
rules in the /config subdir) which redirect any access to anything at 
company.com through to newsite1.org  
The machine that hosts the tomcat instance is set up in the DNS as the 
host for site1.company.com (in fact for all of company.com) and has a 
HOST container in server.xml, viz:

<Host name="company.com"
         debug="3"
         appBase="webapps"
         unpackWARs="true"
         autoDeploy="true">

        <Valve className="org.apache.catalina.valves.AccessLogValve"
          prefix="company_access_log." suffix=".txt"
          pattern="common"/>

         <Alias>site1.company.com</Alias>
    </Host>

and in <tomcat_root>/webapps there is an instance of the balancer app in 
a subdirectory called company.com, with a config file set up to perform 
the necessary redirection for all accesses to anything at company.com

This should work, as far as I can see.  however... although accesses to 
company.com/foobar get successfully redirected to newsite1.org/foobar, 
this setup doesn't forward at all when the root domain is entered - ie 
browsing to company.com or site1.company.com (with no antecedents) just 
results in a blank page.

I'm sure this used to work, and I've tried everything I can think of 
(including fiddling with the vhost definition in server.xml and the 
context fragment in webapps/company.com/company.com.xml) but I just 
can't make it respond to the root case.  Basically, what I'm trying to 
achieve is to get the root of the vhost instance defined in server.xml 
to call up the webapp at webapps/company1.com.   Which you wouldn't have 
thought was that hard - but apparently it is!

The REALLY irritating thing is that I've solved this problem once 
already using pretty much the same setup, but can;t seem to get it to 
work again!
Anyone have any clues or hints or ideas (apart from using apache 
webserver and the AJP setup)? I'd be very grateful if so!

Cheers

Jeremy


---------------------------------------------------------------------
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


Re: Using the balancer app to redirect. Well, trying to... - SOLVED

Posted by Jeremy <je...@paribus.com>.
Hassan Schroeder wrote:
> On 1/9/07, Jeremy <je...@paribus.com> wrote:
>
>> I'm trying to set up a tomcat 5.0.28 instance (on Debian)  to achieve
>> redirecting accesses to site1.company.com through to newsite1.org, using
>> the balancer app. rather than apache webserver and the AJP connectors.
>>
>> The easiest solution would of course be just to set up a DNS level
>> redirect on all port-80 accesses by putting in an A-name record to point
>> at newsite1.org, but the problem is that newsite1.org doesn't have a
>> direct IP, and you can't put the alphanumeric address in the DNS.
>
> I'm afraid I don't understand how name-based virtual hosting is *not*
> the solution to your "problem" here.
>
> It doesn't matter if "newsite1.org" has an IP shared with other hosts or
> domains, so why is it not in DNS?
>
Hi Hassan/Everyone

Thanks for the comment.  Obviously newsite1.org has an IP number 
associated with it (most likely shared), it's just that directly 
accessing it (as eg http://123.456.789.1) brings up an error page from 
the hosting server, which obviously matches on alphas.  Also, the 
interface I have to use to modify the ANAME field will only accept IPs , 
not alphas (with good reason!)

Anyway, problem SOLVED!  For reference, what I had to do was physically 
copy the entire webapps definition directory into conf/Catalina, ratehr 
than just leaving it in tomcat_home/webapps.  For some reason (I suspect 
to do with the priority order that Tomcat looks through the webapps 
directories) this apparently pointless reconfiguration allows the 
balancer instance to properly respond to the root call.  So there it 
is:  a somewhat cranky but possibly useful workaround to VH redirection 
without using AJP or apache.  Hope it helps others out.

Thanks for listening, chaps!

Jeremy

---------------------------------------------------------------------
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


Re: Using the balancer app to redirect. Well, trying to

Posted by Hassan Schroeder <ha...@gmail.com>.
On 1/9/07, Jeremy <je...@paribus.com> wrote:

> I'm trying to set up a tomcat 5.0.28 instance (on Debian)  to achieve
> redirecting accesses to site1.company.com through to newsite1.org, using
> the balancer app. rather than apache webserver and the AJP connectors.
>
> The easiest solution would of course be just to set up a DNS level
> redirect on all port-80 accesses by putting in an A-name record to point
> at newsite1.org, but the problem is that newsite1.org doesn't have a
> direct IP, and you can't put the alphanumeric address in the DNS.

I'm afraid I don't understand how name-based virtual hosting is *not*
the solution to your "problem" here.

It doesn't matter if "newsite1.org" has an IP shared with other hosts or
domains, so why is it not in DNS?

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
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