----- Original Message ----- 
From: "Oli Gauti Gudmundsson" <[EMAIL PROTECTED]>
To: "'Tomcat Users List'" <[EMAIL PROTECTED]>
Sent: Friday, January 18, 2002 11:15 AM
Subject: RE: mod_webapp: redirects to ServerName


> >> If I point my browser to http://www.mydomain.com 
> >> <http://www.mydomain.com> , Apache redirects me to 
> >> http://123.45.67.89/index.jsp <http://123.45.67.89/index.jsp> , where 
> >> 123.45.67.89 is the IP address of the server running the application, 
> >> and is set as the ServerName in httpd.conf.
> 
> > And what is strange here? Apache recognized www.mydomain.com as an alias
> fo a sort and issued a redirect to what he considered to be the real URL.
> 
> What is strange here is that this did not happen before I upgraded to
> mod_webapp. Also, when you have many domain names pointing to the same IP
> address, you do not want all of them to be redirected. For example, if a
> user inputs http://www.mydomain2.com in his browser address window, we dont
> want the address to be changed to 123.45.67.89.

:-) I can understand that.

I'm hosting three virtual hosts on my Apache and it works like a charm. Of course, I 
am using VirtualHost-s in Apache.

> > Yup.
> 
> Here I am showing that this problem is directly connected to the value of
> the ServerName. It seems that mod_webapp redirects all requests to the
> ServerName.

Yes, like I said previously, I would expect Apache to do that, considering you're not 
using virtual hosting like it was intended.

> >> Now the strange thing is, that if I type the full path (with the 
> >> "/index.jsp" at the end), then no redirection occurs.
> 
> > Of course not. If you type http://www.mydomain.com/ you shouldn't see
> redirection. You're getting redirected because of that last slash in the URL
> and it is normal for Apache and web servers in general.
> 
> That's where you are wrong my friend...again. A slash at the end IS NOT
> SUFFICIENT. I have to type THE FULL PATH to not be redirected.

Well, you could be right (of course, you are right, since you're seeing it :-)). 
Basically http://www.mydomain.com will always issue a redirect to 
http://www.mydomain.com/ and that will go for either WelcomePage or DirectoryListing. 
Which includes several Apache modules and opens up an oportunity for Apache to play 
smart. With a full URL, Apache has to be quiet, I guess.

> > And have you defined multiple VirtualHost-s? Of course you haven't. Read
> Apache docs on Virtual Hosts.
> 
> Once again, you are wrong. I have tried defining VirtualHosts, and that
> worked partly, but that is not an acceptable solution for me. Let me explain
> why. My webapp displays different content depending on the hostname, and one
> of the requirements for the webapp is that when more domain names are added
> (all pointing to the same IP address), no configuration or restart should
> have to be done in Apache or Tomcat. You should just have to tell the webapp
> to recognize it.

Well I appologize for my cinical remark up there, but it seamed to me like you were 
trying to do something obviously wrong. The idea you have is a bit problematic. What 
you will have is something that looks like a virtual host to the client, but is not at 
the server. That kind of situation *always* produces cranial pain.

I still believe it is Apache what is bugging you and that is where you have to make a 
change. From Apache's point of view, clients are sending requests to it that it should 
handle (it can see in DNS that those are request to it), but htey are not for that 
exact host, so Apache issues a redirect.

You could try to define a "default virtual host" and map to your web application from 
there, via Warp. Something like:

NameVirtualHost 123.45.67.89

<VirtualHost *:80>
  ServerName 123.45.67.89
  DocumentRoot ...
  ...
  WebAppDeploy my_app / connection
  ...
</VirtualHost>

Nix.


Reply via email to