You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Julian Dunn <Ju...@cbc.ca> on 2008/01/02 22:23:14 UTC

need help with Tomcat-generated redirects

Hi,

I have some applications running under a Tomcat installation set up in this way:

[load balancer on port 80] ---> [Apache server on port 5001] --> [Tomcat server on port 7001]

One of the Tomcat applications sends a redirect to Apache because there is a <welcome-file> directive. However, the redirect that is sent says:

www.site.com:5001/foo/bar.jsp

instead of

www.site.com/foo/bar.jsp

On the Apache side, I already have ServerName set to www.site.com:80 to solve this problem for mod_rewrite. What is the corresponding directive for Tomcat?

- Julian


--
-- Julian C. Dunn, P.Eng.  <Ju...@cbc.ca>
-- Assistant Team Lead, Media Production Support, CBC Technology
-- Digital Programming and Business Development
-- Office: 2C310-N  *  Tel.: (416) 205-3311 x6988 * DID: 1-151-6988



---------------------------------------------------------------------
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: need help with Tomcat-generated redirects

Posted by David Smith <dn...@cornell.edu>.
Connector attribute proxyPort should fix the inclusion of the port 
number in tomcat generated urls.

--David

Julian Dunn wrote:

>Hi,
>
>I have some applications running under a Tomcat installation set up in this way:
>
>[load balancer on port 80] ---> [Apache server on port 5001] --> [Tomcat server on port 7001]
>
>One of the Tomcat applications sends a redirect to Apache because there is a <welcome-file> directive. However, the redirect that is sent says:
>
>www.site.com:5001/foo/bar.jsp
>
>instead of
>
>www.site.com/foo/bar.jsp
>
>On the Apache side, I already have ServerName set to www.site.com:80 to solve this problem for mod_rewrite. What is the corresponding directive for Tomcat?
>
>- Julian
>
>
>--
>-- Julian C. Dunn, P.Eng.  <Ju...@cbc.ca>
>-- Assistant Team Lead, Media Production Support, CBC Technology
>-- Digital Programming and Business Development
>-- Office: 2C310-N  *  Tel.: (416) 205-3311 x6988 * DID: 1-151-6988
>
>
>
>---------------------------------------------------------------------
>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
>
>  
>


---------------------------------------------------------------------
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: need help with Tomcat-generated redirects

Posted by Julian Dunn <Ju...@cbc.ca>.
>>> On Wed, Jan 2, 2008 at  9:10 PM, "Bill Barker" <wb...@wilshire.com> wrote: 

> "Rainer Jung" <ra...@kippdata.de> wrote in message 
> news:477C1B66.2030000@kippdata.de...
>> Hi Julian,
>>
>> Julian Dunn schrieb:
>>>> How do you connect Apache to Tomcat? If you are using mod_jk, the
>>>> module gets the port it sends to Tomcat via ap_get_server_port(),
>>>> which in turn depends on UseCanonicalName. If this is set to On,
>>>> the port is also determined from the port in ServerName.
>>>
>>> I'm using mod_jk 1.2.6 and Apache 2.0.59. UseCanonicalName is already
>>> on in the Apache server, and the ServerName is set to www.site.com:80
>>> in the VirtualHost. I also tried to set ServerName globally and that
>>> didn't make a difference.
>>>
>>> This allows mod_rewrite to send the correct port # in rewrites, but
>>> Tomcat doesn't seem to pick this up for some reason.
>>>
>>> By the way, don't laugh, but this is a legacy Tomcat 3.3.1a
>>> application so I need something for that version of Tomcat.
>>
>> I'm not laughing (at least I try to). Since I'm relatively sure about
>> the jk feature: what about updating to a recent jk version. 1.2.6 is
>> ..., we are at 1.2.26.
>>
> 
> Assuming that you are using the AJP13Interceptor, then updating the mod_jk 
> version should be enough.  The problem is that mod_jk 1.2.6 doesn't respect 
> the UseCanonicalName directive and sends the actual port that Apache is 
> listening on.
> 
> If you are using the CoyoteConnector (which was released as an addon to 
> 3.3.1a), then I think that the proxyPort directive will work.  This 
> connector also ships with 3.3.2, which is a fairly painless upgrade (as 
> opposed to 5.5.x or 6.0.x).

Ok, thanks for your advice, Bill - I'll see what we can do about building a more recent mod_jk to prop this environment up for now. We are using AJP/1.3 so I think that should be fairly safe.

- Julian

---------------------------------------------------------------------
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: need help with Tomcat-generated redirects

Posted by Bill Barker <wb...@wilshire.com>.
"Rainer Jung" <ra...@kippdata.de> wrote in message 
news:477C1B66.2030000@kippdata.de...
> Hi Julian,
>
> Julian Dunn schrieb:
>>> How do you connect Apache to Tomcat? If you are using mod_jk, the
>>> module gets the port it sends to Tomcat via ap_get_server_port(),
>>> which in turn depends on UseCanonicalName. If this is set to On,
>>> the port is also determined from the port in ServerName.
>>
>> I'm using mod_jk 1.2.6 and Apache 2.0.59. UseCanonicalName is already
>> on in the Apache server, and the ServerName is set to www.site.com:80
>> in the VirtualHost. I also tried to set ServerName globally and that
>> didn't make a difference.
>>
>> This allows mod_rewrite to send the correct port # in rewrites, but
>> Tomcat doesn't seem to pick this up for some reason.
>>
>> By the way, don't laugh, but this is a legacy Tomcat 3.3.1a
>> application so I need something for that version of Tomcat.
>
> I'm not laughing (at least I try to). Since I'm relatively sure about
> the jk feature: what about updating to a recent jk version. 1.2.6 is
> ..., we are at 1.2.26.
>

Assuming that you are using the AJP13Interceptor, then updating the mod_jk 
version should be enough.  The problem is that mod_jk 1.2.6 doesn't respect 
the UseCanonicalName directive and sends the actual port that Apache is 
listening on.

If you are using the CoyoteConnector (which was released as an addon to 
3.3.1a), then I think that the proxyPort directive will work.  This 
connector also ships with 3.3.2, which is a fairly painless upgrade (as 
opposed to 5.5.x or 6.0.x).

> I never worked with TC 3.3, but the docs tell us, that it allows an
> AJP13 connector, so that one should be compatible with recent JK
> versions. In case you are still using AJP12, that's not a safe bet to
> use AJP12 with recent JK.
>

Yes, the AJP/1.2 connector was deprecated even for 3.3.1a  (except as a way 
to shut Tomcat down :).    To get this to work, you'll have to be using the 
AJP/1.3 protocol.

> The docs look like the connector attributes we posted as an alternative
> solution unfortunately don't exist for 3.3.
>
>> - Julian
>
> Regards,
>
> Rainer
>
> ---------------------------------------------------------------------
> 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
>
> 




---------------------------------------------------------------------
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: need help with Tomcat-generated redirects

Posted by Rainer Jung <ra...@kippdata.de>.
Hi Julian,

Julian Dunn schrieb:
>> How do you connect Apache to Tomcat? If you are using mod_jk, the
>> module gets the port it sends to Tomcat via ap_get_server_port(),
>> which in turn depends on UseCanonicalName. If this is set to On,
>> the port is also determined from the port in ServerName.
> 
> I'm using mod_jk 1.2.6 and Apache 2.0.59. UseCanonicalName is already
> on in the Apache server, and the ServerName is set to www.site.com:80
> in the VirtualHost. I also tried to set ServerName globally and that
> didn't make a difference.
> 
> This allows mod_rewrite to send the correct port # in rewrites, but
> Tomcat doesn't seem to pick this up for some reason.
> 
> By the way, don't laugh, but this is a legacy Tomcat 3.3.1a
> application so I need something for that version of Tomcat.

I'm not laughing (at least I try to). Since I'm relatively sure about
the jk feature: what about updating to a recent jk version. 1.2.6 is
..., we are at 1.2.26.

I never worked with TC 3.3, but the docs tell us, that it allows an
AJP13 connector, so that one should be compatible with recent JK
versions. In case you are still using AJP12, that's not a safe bet to
use AJP12 with recent JK.

The docs look like the connector attributes we posted as an alternative
solution unfortunately don't exist for 3.3.

> - Julian

Regards,

Rainer

---------------------------------------------------------------------
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: need help with Tomcat-generated redirects

Posted by Julian Dunn <Ju...@cbc.ca>.
>>> On Wed, Jan 2, 2008 at  4:48 PM, Rainer Jung <ra...@kippdata.de> wrote: 

>> I have some applications running under a Tomcat installation set up
>> in this way:
>> 
>> [load balancer on port 80] ---> [Apache server on port 5001] -->
>> [Tomcat server on port 7001]
>> 
>> One of the Tomcat applications sends a redirect to Apache because
>> there is a <welcome-file> directive. However, the redirect that is
>> sent says:
>> 
>> www.site.com:5001/foo/bar.jsp
>> 
>> instead of
>> 
>> www.site.com/foo/bar.jsp
>> 
>> On the Apache side, I already have ServerName set to www.site.com:80
>> to solve this problem for mod_rewrite. What is the corresponding
>> directive for Tomcat?
> 
> How do you connect Apache to Tomcat?
> If you are using mod_jk, the module gets the port it sends to Tomcat via
> ap_get_server_port(), which in turn depends on UseCanonicalName. If this
> is set to On, the port is also determined from the port in ServerName.

I'm using mod_jk 1.2.6 and Apache 2.0.59. UseCanonicalName is already on in the Apache server, and the ServerName is set to www.site.com:80 in the VirtualHost. I also tried to set ServerName globally and that didn't make a difference.

This allows mod_rewrite to send the correct port # in rewrites, but Tomcat doesn't seem to pick this up for some reason.

By the way, don't laugh, but this is a legacy Tomcat 3.3.1a application so I need something for that version of Tomcat.

- Julian


---------------------------------------------------------------------
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: need help with Tomcat-generated redirects

Posted by Rainer Jung <ra...@kippdata.de>.
Hi Julian,

Julian Dunn schrieb:
> Hi,
> 
> I have some applications running under a Tomcat installation set up
> in this way:
> 
> [load balancer on port 80] ---> [Apache server on port 5001] -->
> [Tomcat server on port 7001]
> 
> One of the Tomcat applications sends a redirect to Apache because
> there is a <welcome-file> directive. However, the redirect that is
> sent says:
> 
> www.site.com:5001/foo/bar.jsp
> 
> instead of
> 
> www.site.com/foo/bar.jsp
> 
> On the Apache side, I already have ServerName set to www.site.com:80
> to solve this problem for mod_rewrite. What is the corresponding
> directive for Tomcat?

How do you connect Apache to Tomcat?
If you are using mod_jk, the module gets the port it sends to Tomcat via
ap_get_server_port(), which in turn depends on UseCanonicalName. If this
is set to On, the port is also determined from the port in ServerName.

The AJP protocol then makes sure, that Tomcat thinks it's using the port
that mod_jk told Tomcat.

In case this doesn't work or you are using some other way to connect
Apache to Tomcat:

The connector element in server.xml knows about attributes proxyName,
proxyPort and scheme. See

http://tomcat.apache.org/tomcat-6.0-doc/config/http.html

> - Julian

Regards,

Rainer

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