You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by James Tolles <to...@corp.earthlink.net> on 2003/05/13 00:11:41 UTC

mod_jk Apache "useCanonicalName" sendRedirect

We are using apache1.3/tomcat3.2.4 over mod_jk, using ajp13.

 

Our server is behind a load balancer that translates port 443 to 8443.

 

So, in our servlet code,  when we issue a "response.sendRedirect()", with a
relative url,  tomcat builds an absolute URL - that has port 8443 instead of
the clients port of 443.

 

Apache has a parameter "UseCanonicalName". The apache doc says, that if this
is set "off" then the apache server with use the "clients" serverName and
port for CGI variables  server_name and server_port.

 

This would work for us. Setting UseCanonicalName to off, we get, from the
call request.getServerName() the client's serverName and not the Apache
serverName; however, the port number we get from request.getServerPort() is
always the actual port the server is listening on, and not the clients port.

 

Is there a way to configure Apache/Tomcat mod_jk so that
request.getServerPort() returns the clients portnumber, in the same way that
setting "UseCanoncialName" works for getting the clients servername.

 

The apache doc on UseCanonicalName says:

 

With UseCanonicalName off Apache will form self-referential URLs using the
hostname and port supplied by the client if any are supplied (otherwise it
will use the canonical name, as defined above). These values are the same
that are used to implement name based
<file:///D:\apache\Apache\htdocs\manual\vhosts\name-based.html>  virtual
hosts, and are available with the same clients. The CGI variables
SERVER_NAME and SERVER_PORT will be constructed from the client supplied
values as well.

 

So, it seems like the mod_jk connection from Apache to tomcat  supports the
CGI variable "SERVER_NAME" for the call request.getServerName(), but does
not support the CGI variable name for SERVER_PORT for the call
request.getServerPort(). Is there away to get both the clients serverName
and serverPort from Apache?

 

Thanks in advance,

 

 James


Re: mod_jk Apache "useCanonicalName" sendRedirect

Posted by Tim Funk <fu...@joedog.org>.
Warning ... very very long thread, grab some coffee and popcorn before reading.

http://marc.theaimsgroup.com/?t=103054100800003&r=1&w=2

-Tim


James Tolles wrote:
> We're trying to avoid that - build our own absolute url from the request
> object ( get the scheme, get the host header and build ).
> 
> It seems like Apache does set both serverNAme and serverPort from the client
> when UseCanonicalName is "off" - but tomcat is not getting the port via
> mod_jk. Would you recall if the discussion centered around Apache? Of
> Tomcat? Or mod_jk?
> 
> Thanks
>    James
> 
> -----Original Message-----
> From: Tim Funk [mailto:funkman@joedog.org] 
> Sent: Monday, May 12, 2003 4:00 PM
> To: Tomcat Users List
> Subject: Re: mod_jk Apache "useCanonicalName" sendRedirect
> 
> I remember lots of discussions around this. (or very similar) All of them 
> painful, very painful. (Mainly because of different interpretations in the 
> spec with respect to the port) I also forget the end result of those
> discussions.
> 
> If you really need the server name and server port, a good way is to use the
> 
> "Host" header. More information on the host header:
> http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23
> 
> 
> -Tim
> 
> James Tolles wrote:
> 
>>We are using apache1.3/tomcat3.2.4 over mod_jk, using ajp13.
>>
>> 
>>
>>Our server is behind a load balancer that translates port 443 to 8443.
>>
>> 
>>
>>So, in our servlet code,  when we issue a "response.sendRedirect()", with
> 
> a
> 
>>relative url,  tomcat builds an absolute URL - that has port 8443 instead
> 
> of
> 
>>the clients port of 443.
>>
>> 
>>
>>Apache has a parameter "UseCanonicalName". The apache doc says, that if
> 
> this
> 
>>is set "off" then the apache server with use the "clients" serverName and
>>port for CGI variables  server_name and server_port.
>>
>> 
>>
>>This would work for us. Setting UseCanonicalName to off, we get, from the
>>call request.getServerName() the client's serverName and not the Apache
>>serverName; however, the port number we get from request.getServerPort()
> 
> is
> 
>>always the actual port the server is listening on, and not the clients
> 
> port.
> 
>> 
>>
>>Is there a way to configure Apache/Tomcat mod_jk so that
>>request.getServerPort() returns the clients portnumber, in the same way
> 
> that
> 
>>setting "UseCanoncialName" works for getting the clients servername.
>>
>> 
>>
>>The apache doc on UseCanonicalName says:
>>
>> 
>>
>>With UseCanonicalName off Apache will form self-referential URLs using the
>>hostname and port supplied by the client if any are supplied (otherwise it
>>will use the canonical name, as defined above). These values are the same
>>that are used to implement name based
>><file:///D:\apache\Apache\htdocs\manual\vhosts\name-based.html>  virtual
>>hosts, and are available with the same clients. The CGI variables
>>SERVER_NAME and SERVER_PORT will be constructed from the client supplied
>>values as well.
>>
>> 
>>
>>So, it seems like the mod_jk connection from Apache to tomcat  supports
> 
> the
> 
>>CGI variable "SERVER_NAME" for the call request.getServerName(), but does
>>not support the CGI variable name for SERVER_PORT for the call
>>request.getServerPort(). Is there away to get both the clients serverName
>>and serverPort from Apache?
>>
>> 
>>
>>Thanks in advance,
>>
>> 
>>
>> James
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 
> 


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


RE: mod_jk Apache "useCanonicalName" sendRedirect

Posted by James Tolles <to...@corp.earthlink.net>.
We're trying to avoid that - build our own absolute url from the request
object ( get the scheme, get the host header and build ).

It seems like Apache does set both serverNAme and serverPort from the client
when UseCanonicalName is "off" - but tomcat is not getting the port via
mod_jk. Would you recall if the discussion centered around Apache? Of
Tomcat? Or mod_jk?

Thanks
   James

-----Original Message-----
From: Tim Funk [mailto:funkman@joedog.org] 
Sent: Monday, May 12, 2003 4:00 PM
To: Tomcat Users List
Subject: Re: mod_jk Apache "useCanonicalName" sendRedirect

I remember lots of discussions around this. (or very similar) All of them 
painful, very painful. (Mainly because of different interpretations in the 
spec with respect to the port) I also forget the end result of those
discussions.

If you really need the server name and server port, a good way is to use the

"Host" header. More information on the host header:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23


-Tim

James Tolles wrote:
> We are using apache1.3/tomcat3.2.4 over mod_jk, using ajp13.
> 
>  
> 
> Our server is behind a load balancer that translates port 443 to 8443.
> 
>  
> 
> So, in our servlet code,  when we issue a "response.sendRedirect()", with
a
> relative url,  tomcat builds an absolute URL - that has port 8443 instead
of
> the clients port of 443.
> 
>  
> 
> Apache has a parameter "UseCanonicalName". The apache doc says, that if
this
> is set "off" then the apache server with use the "clients" serverName and
> port for CGI variables  server_name and server_port.
> 
>  
> 
> This would work for us. Setting UseCanonicalName to off, we get, from the
> call request.getServerName() the client's serverName and not the Apache
> serverName; however, the port number we get from request.getServerPort()
is
> always the actual port the server is listening on, and not the clients
port.
> 
>  
> 
> Is there a way to configure Apache/Tomcat mod_jk so that
> request.getServerPort() returns the clients portnumber, in the same way
that
> setting "UseCanoncialName" works for getting the clients servername.
> 
>  
> 
> The apache doc on UseCanonicalName says:
> 
>  
> 
> With UseCanonicalName off Apache will form self-referential URLs using the
> hostname and port supplied by the client if any are supplied (otherwise it
> will use the canonical name, as defined above). These values are the same
> that are used to implement name based
> <file:///D:\apache\Apache\htdocs\manual\vhosts\name-based.html>  virtual
> hosts, and are available with the same clients. The CGI variables
> SERVER_NAME and SERVER_PORT will be constructed from the client supplied
> values as well.
> 
>  
> 
> So, it seems like the mod_jk connection from Apache to tomcat  supports
the
> CGI variable "SERVER_NAME" for the call request.getServerName(), but does
> not support the CGI variable name for SERVER_PORT for the call
> request.getServerPort(). Is there away to get both the clients serverName
> and serverPort from Apache?
> 
>  
> 
> Thanks in advance,
> 
>  
> 
>  James
> 
> 


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


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


Re: mod_jk Apache "useCanonicalName" sendRedirect

Posted by Tim Funk <fu...@joedog.org>.
I remember lots of discussions around this. (or very similar) All of them 
painful, very painful. (Mainly because of different interpretations in the 
spec with respect to the port) I also forget the end result of those discussions.

If you really need the server name and server port, a good way is to use the 
"Host" header. More information on the host header:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23


-Tim

James Tolles wrote:
> We are using apache1.3/tomcat3.2.4 over mod_jk, using ajp13.
> 
>  
> 
> Our server is behind a load balancer that translates port 443 to 8443.
> 
>  
> 
> So, in our servlet code,  when we issue a "response.sendRedirect()", with a
> relative url,  tomcat builds an absolute URL - that has port 8443 instead of
> the clients port of 443.
> 
>  
> 
> Apache has a parameter "UseCanonicalName". The apache doc says, that if this
> is set "off" then the apache server with use the "clients" serverName and
> port for CGI variables  server_name and server_port.
> 
>  
> 
> This would work for us. Setting UseCanonicalName to off, we get, from the
> call request.getServerName() the client's serverName and not the Apache
> serverName; however, the port number we get from request.getServerPort() is
> always the actual port the server is listening on, and not the clients port.
> 
>  
> 
> Is there a way to configure Apache/Tomcat mod_jk so that
> request.getServerPort() returns the clients portnumber, in the same way that
> setting "UseCanoncialName" works for getting the clients servername.
> 
>  
> 
> The apache doc on UseCanonicalName says:
> 
>  
> 
> With UseCanonicalName off Apache will form self-referential URLs using the
> hostname and port supplied by the client if any are supplied (otherwise it
> will use the canonical name, as defined above). These values are the same
> that are used to implement name based
> <file:///D:\apache\Apache\htdocs\manual\vhosts\name-based.html>  virtual
> hosts, and are available with the same clients. The CGI variables
> SERVER_NAME and SERVER_PORT will be constructed from the client supplied
> values as well.
> 
>  
> 
> So, it seems like the mod_jk connection from Apache to tomcat  supports the
> CGI variable "SERVER_NAME" for the call request.getServerName(), but does
> not support the CGI variable name for SERVER_PORT for the call
> request.getServerPort(). Is there away to get both the clients serverName
> and serverPort from Apache?
> 
>  
> 
> Thanks in advance,
> 
>  
> 
>  James
> 
> 


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