You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by d tbsky <tb...@gmail.com> on 2009/06/12 11:33:51 UTC

canonical hostnames for tomcat server

Hi:
    i have a tomcat server, which can be access by many ways, like

   http://portal.example.com
   http://portal
   http://192.168.1.1

   i want to user to use only "http://portal.example.com". other ways
will be redirect to the canonical hostname.

   i found i can do this with  "apache + mod_rewrite + tomcat"  or
"tomcat + urlrewritefilter".

   i wonder if there are simpler solutions. can tomcat do this by
itself via configuration?

thanks for help!!

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


Re: canonical hostnames for tomcat server

Posted by André Warnier <aw...@ice-sa.com>.
d tbsky wrote:
> Hi:
>     i have a tomcat server, which can be access by many ways, like
> 
>    http://portal.example.com
>    http://portal
>    http://192.168.1.1
> 
>    i want to user to use only "http://portal.example.com". other ways
> will be redirect to the canonical hostname.
> 
>    i found i can do this with  "apache + mod_rewrite + tomcat"  or
> "tomcat + urlrewritefilter".
> 
>    i wonder if there are simpler solutions. can tomcat do this by
> itself via configuration?
> 
As a pragmatic immediate reaction :
the two methods you mention are available, they work, they are free, 
they are documented, they can do much more than this if you need it, and 
someone else has developed them and is taking care of fixing the bugs in 
them.  What else do you want ?
;-)


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


Re: canonical hostnames for tomcat server

Posted by d tbsky <tb...@gmail.com>.
hi :

   Thanks a lot for all the information. in fact my
http://portal.example.com is a liferay portal server. i need a
canonical hostname because liferay need it to function 100% correctly.

   Finally i choose to use tomcat+urlrewritefilter, and i found that
liferay+tomcat bundle already include urlrewritefilter to do some
filter things.  so i just need to add the canonical hostname rule to
it.

   I was hesitate because i saw somebody complain about the speed of
urlrewritefilter. but i didn't notice speed difference after i apply
the rule.

  thanks again for all the suggestion. i am a happy administrator now.

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


Re: canonical hostnames for tomcat server

Posted by André Warnier <aw...@ice-sa.com>.
Caldarale, Charles R wrote:
>> From: Mark Shifman [mailto:mark.shifman@yale.edu]
>> Subject: Re: canonical hostnames for tomcat server
>>
>> host name aliases may help
>> http://tomcat.apache.org/tomcat-6.0-doc/config/host.html#Host%20Name%20Aliases
> 
> I don't think aliases will do it.  Look at virtual hosting in Tomcat:
> http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html
> 
> Set up an additional <Host> with a name attribute of "portal.example.com" with an appBase that points to the webapps you want to use with that domain.  Any requests that do not match that specific domain will be handled by the <Engine>'s defaultHost, which you can leave as "localhost".
> 
I think the OP not only wants to have the requests handled by the host 
whose name corresponds to the one in the request.
He also wants, if this request hostname is /not/ the canonical one 
myhost.company.com, to /not/ serve the request, but (externally) 
re-direct the browser to the canonical host.
In other words, he wants to "educate" his users.

I suppose you could still do it with 2 <Host> sections, the non-default 
being the canonical one which answers normally, and the default <Host> 
having /something/ inside which returns a 301 (?) redirect for every 
request, to the canonical one.
How would one do this under Tomcat however ?
Create a default servlet which processes all requests and always issues 
a re-direct response ? or is there a simpler solution ?

That's why I was saying that the simplest solutions may well be the ones 
he mentioned at the beginning.


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


RE: canonical hostnames for tomcat server

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Mark Shifman [mailto:mark.shifman@yale.edu]
> Subject: Re: canonical hostnames for tomcat server
> 
> host name aliases may help
> http://tomcat.apache.org/tomcat-6.0-doc/config/host.html#Host%20Name%20Aliases

I don't think aliases will do it.  Look at virtual hosting in Tomcat:
http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html

Set up an additional <Host> with a name attribute of "portal.example.com" with an appBase that points to the webapps you want to use with that domain.  Any requests that do not match that specific domain will be handled by the <Engine>'s defaultHost, which you can leave as "localhost".

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


Re: canonical hostnames for tomcat server

Posted by Mark Shifman <ma...@yale.edu>.
host name aliases may help
http://tomcat.apache.org/tomcat-6.0-doc/config/host.html#Host%20Name%20Aliases

d tbsky wrote:
> Hi:
>     i have a tomcat server, which can be access by many ways, like
> 
>    http://portal.example.com
>    http://portal
>    http://192.168.1.1
> 
>    i want to user to use only "http://portal.example.com". other ways
> will be redirect to the canonical hostname.
> 
>    i found i can do this with  "apache + mod_rewrite + tomcat"  or
> "tomcat + urlrewritefilter".
> 
>    i wonder if there are simpler solutions. can tomcat do this by
> itself via configuration?
> 
> thanks for help!!
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

-- 
 Mark Shifman MD. Ph.D.
 Yale Center for Medical Informatics
 Phone (203)737-5219
 mark.shifman@yale.edu

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