Bug 35959 - mod_jk not independant of UseCanonicalName
Summary: mod_jk not independant of UseCanonicalName
Status: RESOLVED WONTFIX
Alias: None
Product: Tomcat Connectors
Classification: Unclassified
Component: mod_jk (show other bugs)
Version: unspecified
Hardware: Other other
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-01 07:56 UTC by Sven
Modified: 2017-12-07 10:22 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sven 2005-08-01 07:56:48 UTC
Hi,

people must enable apache's UseCanonicalName-option to make sure, that mod_jk
sends the servername (and not the http-hosh-header value) to tomcat.

It would be nice to leave UseCanonicalName off and instead set a mod_jk specific
option for it.
Comment 1 william.barker 2005-08-01 09:21:52 UTC
The servlet spec (@see section 14.2.16) is very specific that 
request.getServerName() must be the value of the Host header.
Comment 2 Sven 2005-08-01 09:39:53 UTC
I feel a bit misunderstood.

I'm sure, the Servlet Spec is clear about HTTP-Headers. The HTTP-Headers should
be transmitted unchanged to Tomcat, no dought!

The thing i talk about is the AJP13 layer. Beside the headers, mod_jk sends
another field. You talked about it in Bug 34648. You called it
request.getLocalName()

I'd like mod_jk to alway send the servername of apache's vhost no matter what
UseCanonicalName is set to.
Comment 3 Sven 2005-08-01 09:48:19 UTC
Addition:

I will refer to http://jakarta.apache.org/tomcat/connectors-doc/common/ajpv13a.html

AJP13_FORWARD_REQUEST contains a field called "server_name". I expect this to
the what you referred to as request.getLocalName().

I'd like an option for mod_jk, so that field "server_name" always matches the
ServerName of apache's vhost - which is not the case AFAIK.
Comment 4 Remy Maucherat 2005-08-01 09:58:16 UTC
This field is meant to implement the new Servlet API call, nothing more, nothing
less.
Comment 5 Sven 2005-08-01 10:31:37 UTC
Section 14.2.16 doesn't say anything, how this data is obtained - for example
whether the result of getLocalName() is obtained by a DNS-reverselookup or by
using the host-header or the name of the host like it is stored in tomcat's config.

Well, there's no secure source for that _except_ a reverselookup. The
host-header isn't reliable, so why should the data send by mod_jk be? Well, it
isn't, since mod_jk sends the host-header if UseCanonicalName iss off and sends
the ServerName of apache's vhost if UseCanonicalName is enabled.

So where's you're point?
Comment 6 Rainer Jung 2008-01-03 05:36:36 UTC
Could you please explain your use case? I think it's good, that you can switch
the behaviour with UseCanonicalName, because it makes the behaviour of the
reverse proxy consistent with a single directive. Why do you need to have
UseCanonicalName set to off and still want mod_jk to send the data extracted
from ServerName to Tomcat?
Comment 7 Sven 2008-01-03 15:12:52 UTC
UseCanonialName was simply unwanted by me. I didn't want users to be redirected
between domains just because they hit one of Apache's redirection.
That also causes losing of the session, doesn't it?

At the same time, i wouldn't want to clone a rather complicated VirtualHost
config in Tomcat. Whatever VirtualHost Apache chooses, i want to be sure, which
Host will be used on the Tomcat side. I'd like a clear association, instead of
two configs which i have to keep in sync.
Actually i ask myself, if any Apache-config can be represented by a Tomcat-config.


The easiest (and only) way for a clean association between Apache and Tomcat
Hosts was (and still is?), to "UseCanonialName on" on Apache side and
useIPVHosts="true" on Tomcat side.
Comment 8 Rainer Jung 2008-01-05 09:31:26 UTC
I don't really understand your answer, maybe there are to many aspects in it.

Could we start simple: please give a basic setup where your initial statement
applies:

"It would be nice to leave UseCanonicalName off and instead set a mod_jk specific
option for it."

Please give a concrete example.
Comment 9 Rainer Jung 2011-10-25 18:08:21 UTC
No response in nearly 4 years.
User didn't provide a concrete use case for the feature.
Comment 10 Sven 2011-10-25 19:03:59 UTC
(In reply to comment #9)
> No response in nearly 4 years.
> User didn't provide a concrete use case for the feature.

UseCanonicalName influences things like redirects on the apache side. As far as I can recall, a redirect will use the canonical name if UseCanonicalName=on. That behaviour of apache can be totally undesired, since obviously the http client would be redirected to another domain and therefor cookies will be invalid 
and whatnot.

On the other hand, UseCanonicalName=on was the only way to make sure that a http-request that matched a certain vhost on the apache site goes to a specific tomcat vhost. With UseCanonicalName=off you would basically have to adjust the tomcat config so that resembles the apache config with its servernames and serveraliases as close as possible. I'm not sure, if the latter is even possible in any case. The apache configuration language might be more powerful than the tomcat's.

So with respect to mod_jk, UseCanonicalName=on can be desired  while at the same time UseCanonicalName=off can be desired for redirect on the apache side.
Comment 11 Mark Thomas 2017-12-07 10:22:09 UTC
I understand the use case.

Using the canonical name on the Tomcat side is going to trigger the same set of issues (e.g. broken cookies) as it triggers on the httpd side. The subset of users for which this is not a concern is going to be very small.

It should be possible to configure Tomcat's virtual hosts to align with httpd's. Since this issue was raised Tomcat added limited support for wildcards (see bug 18500).

Depending on the exact requirements, it is likely that other httpd configuration options (mod_headers, mod_rewrite, etc.) can be used to achieve the desired results.