You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Cindy Ballreich <ci...@ballreich.net> on 2003/03/11 22:46:19 UTC

problem with hyphen in hostname

I've recently noticed a problem that occurs when I access my site using a domain name with a hyphen in it. It seems that when I navigate using dispatcher.forward everything works fine. But when I use response.sendRedirect the hyphen is lost. Since we also own the same domain name without the hyphen, the redirection works, but a new session is created requiring the user to be re-authenticated. (The hyphenated domain name is preferred over the non-hyphenated one.)

I've printed out request.getRequestURL() and the hyphen is also missing from this value. I've tried several of our other domain names (all legal for this server) and they all work properly. The only one with problems is the hyphenated one.

Is this a problem with Tomcat or am I doing something wrong?

Tomcat 4.1.18
Apache 1.3.26
mod_jk
RedHat Linux 7.3

I'd be happy to provide any other info.

Thanks

Cindy

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: problem with hyphen in hostname

Posted by Bill Barker <wb...@wilshire.com>.
Ok, I now see the problem.  In my case I'm using NamedVirtualHost to send to
different Tomcat instances (and it works fine).  It seems that the Jk module
of Tomcat isn't parsing the Host header correctly when you have multiple
hosts sending to the same Tomcat instance.  I'd suggest submitting a bug
report to http://nagoya.apache.org/bugzilla/ so that this doesn't get lost
in the traffic.

"Cindy Ballreich" <ci...@ballreich.net> wrote in message
news:3.0.5.32.20030312085133.01a2d100@urchin...
> Here's a little more info...
>
> The problem is that the hyphenated hostname being given to the browser
(www.first-last.com) is being changed by the servlet and the hyphen is being
removed (www.firstlast.com). (Of course that's not a real domain name but it
illustrates what's happening more clearly.) Both domains are legitimate for
this server. Both are recognized by Apache. The actual hostname (from
/etc/hosts) is something completely different.
>
> All of this is taking place in the servlet. I haven't tested this in a jsp
page.
>
> When I give response.sendRedirect() a relative url, I notice that the
hostname is changing in the browser's location bar. Absolute urls are not a
problem.
>
> In testing, I noticed that request.getRequestURL() and
request.getServerName() also return the hostname without the hyphen.
>
> Further testing found that request.getHeader("host") returned the
correctly hyphenated hostname given when the servlet was called by the
browser.
>
> The workaround I'm using is to build an absolute url using the hostname
from the header and redirect to that url instead of the relative url I'd
been using.
>
> Is this expected behavior? It would seem to me that the hostname given in
the user's browser's location bar should be being maintained throughout the
session unless changed by a redirection. (Which of course is what's
happening.) I don't understand why the redirection and the two request
methods are dropping the hyphen. Am I doing something wrong?
>
> Thanks
>
> Cindy
>
> At 11:26 PM 3/11/03 -0800, Bill Barker wrote:
> >I just tested this, and it works for me.  My first guess would be that
the
> ><Host> tag is setup wrong.
> >
> >This is a bit strange, but it should be easy enough to debug.  Try doing:
> >$ telnet my-host.mycompany.com 80
> >...
> >GET /myapp/my-page-that-does-a-redirect HTTP/1.0
> >Host: my-host.mycompany.com
> >
> >Of course, substitute in real information for 'my-host', 'mycompany.com',
> >and the URL.  If the response is pointing to a different host, then
you've
> >likely got a configuration problem (but it should at least give you hints
on
> >where to look).
> >
> >"Cindy Ballreich" <ci...@ballreich.net> wrote in message
> >news:3.0.5.32.20030311134619.00acab20@urchin...
> >>
> >> I've recently noticed a problem that occurs when I access my site using
a
> >domain name with a hyphen in it. It seems that when I navigate using
> >dispatcher.forward everything works fine. But when I use
> >response.sendRedirect the hyphen is lost. Since we also own the same
domain
> >name without the hyphen, the redirection works, but a new session is
created
> >requiring the user to be re-authenticated. (The hyphenated domain name is
> >preferred over the non-hyphenated one.)
> >>
> >> I've printed out request.getRequestURL() and the hyphen is also missing
> >from this value. I've tried several of our other domain names (all legal
for
> >this server) and they all work properly. The only one with problems is
the
> >hyphenated one.
> >>
> >> Is this a problem with Tomcat or am I doing something wrong?
> >>
> >> Tomcat 4.1.18
> >> Apache 1.3.26
> >> mod_jk
> >> RedHat Linux 7.3
> >>
> >> I'd be happy to provide any other info.
> >>
> >> Thanks
> >>
> >> Cindy
> >




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: problem with hyphen in hostname

Posted by Cindy Ballreich <ci...@ballreich.net>.
Here's a little more info...

The problem is that the hyphenated hostname being given to the browser (www.first-last.com) is being changed by the servlet and the hyphen is being removed (www.firstlast.com). (Of course that's not a real domain name but it illustrates what's happening more clearly.) Both domains are legitimate for this server. Both are recognized by Apache. The actual hostname (from /etc/hosts) is something completely different. 

All of this is taking place in the servlet. I haven't tested this in a jsp page.

When I give response.sendRedirect() a relative url, I notice that the hostname is changing in the browser's location bar. Absolute urls are not a problem.

In testing, I noticed that request.getRequestURL() and request.getServerName() also return the hostname without the hyphen.

Further testing found that request.getHeader("host") returned the correctly hyphenated hostname given when the servlet was called by the browser.

The workaround I'm using is to build an absolute url using the hostname from the header and redirect to that url instead of the relative url I'd been using.

Is this expected behavior? It would seem to me that the hostname given in the user's browser's location bar should be being maintained throughout the session unless changed by a redirection. (Which of course is what's happening.) I don't understand why the redirection and the two request methods are dropping the hyphen. Am I doing something wrong?

Thanks

Cindy

At 11:26 PM 3/11/03 -0800, Bill Barker wrote:
>I just tested this, and it works for me.  My first guess would be that the
><Host> tag is setup wrong.
>
>This is a bit strange, but it should be easy enough to debug.  Try doing:
>$ telnet my-host.mycompany.com 80
>...
>GET /myapp/my-page-that-does-a-redirect HTTP/1.0
>Host: my-host.mycompany.com
>
>Of course, substitute in real information for 'my-host', 'mycompany.com',
>and the URL.  If the response is pointing to a different host, then you've
>likely got a configuration problem (but it should at least give you hints on
>where to look).
>
>"Cindy Ballreich" <ci...@ballreich.net> wrote in message
>news:3.0.5.32.20030311134619.00acab20@urchin...
>>
>> I've recently noticed a problem that occurs when I access my site using a
>domain name with a hyphen in it. It seems that when I navigate using
>dispatcher.forward everything works fine. But when I use
>response.sendRedirect the hyphen is lost. Since we also own the same domain
>name without the hyphen, the redirection works, but a new session is created
>requiring the user to be re-authenticated. (The hyphenated domain name is
>preferred over the non-hyphenated one.)
>>
>> I've printed out request.getRequestURL() and the hyphen is also missing
>from this value. I've tried several of our other domain names (all legal for
>this server) and they all work properly. The only one with problems is the
>hyphenated one.
>>
>> Is this a problem with Tomcat or am I doing something wrong?
>>
>> Tomcat 4.1.18
>> Apache 1.3.26
>> mod_jk
>> RedHat Linux 7.3
>>
>> I'd be happy to provide any other info.
>>
>> Thanks
>>
>> Cindy
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: problem with hyphen in hostname

Posted by Bill Barker <wb...@wilshire.com>.
I just tested this, and it works for me.  My first guess would be that the
<Host> tag is setup wrong.

This is a bit strange, but it should be easy enough to debug.  Try doing:
$ telnet my-host.mycompany.com 80
...
GET /myapp/my-page-that-does-a-redirect HTTP/1.0
Host: my-host.mycompany.com

Of course, substitute in real information for 'my-host', 'mycompany.com',
and the URL.  If the response is pointing to a different host, then you've
likely got a configuration problem (but it should at least give you hints on
where to look).

"Cindy Ballreich" <ci...@ballreich.net> wrote in message
news:3.0.5.32.20030311134619.00acab20@urchin...
>
> I've recently noticed a problem that occurs when I access my site using a
domain name with a hyphen in it. It seems that when I navigate using
dispatcher.forward everything works fine. But when I use
response.sendRedirect the hyphen is lost. Since we also own the same domain
name without the hyphen, the redirection works, but a new session is created
requiring the user to be re-authenticated. (The hyphenated domain name is
preferred over the non-hyphenated one.)
>
> I've printed out request.getRequestURL() and the hyphen is also missing
from this value. I've tried several of our other domain names (all legal for
this server) and they all work properly. The only one with problems is the
hyphenated one.
>
> Is this a problem with Tomcat or am I doing something wrong?
>
> Tomcat 4.1.18
> Apache 1.3.26
> mod_jk
> RedHat Linux 7.3
>
> I'd be happy to provide any other info.
>
> Thanks
>
> Cindy




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org