"Ryan Lissack" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> In our setup we have a hardware load-balancer which forwards normal
requests
> to our cluster of Tomcat servers.  For SSL requests, the load balancer
first
> forwards to an hardware SSL accelerator and then on to one of our Tomcat
> servers.  Each Tomcat instance has 2 connectors configured.
>
> For normal requests, clients connect to load balancer on port 80 and the
> load balancer then forwards the request to a Tomcat instance on port 8800.
>
> For secure requests, clients connect to the load balancer on port 443, the
> load balancer then forwards to the SSL accelerator and then the load
> balancer forwards to a Tomcat instance on port 8801.
>
> The problem I am having is that the getServerPort method *always* returns
80
> for all requests even though I know they were received on either port 8800
> or 8801 (netstat also confirms this).  If I connect directly to the
servers
> (http://server:8800), the port is correctly reported.
>
> I can access the correct port by inspecting the incoming requests using
> reflection (request.request.connector.port) but this is obviously far from
> ideal (non-portable etc).
>
> Does anyone have an idea why this is occurring or perhaps a way around the
> problem ?

This is occurring because getServerPort returns the value that the request
was sent to (i.e. the value in the 'Host' HTTP header).  This is necessary
so that it is possible to form URLs that refer back to the server (e.g.
response.sendRedirect).

The way around the problem is to upgrade to Tomcat 5, and use
request.getLocalPort.  This returns the port that the request was received
on.

>
> Thanks,
> Ryan.
>
> Tomcat 4.1.24, Sun Java 1.4.2, RedHat 9




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to