You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2006/12/30 00:41:28 UTC

DO NOT REPLY [Bug 41263] New: - servletRequest.getRemotePort() returns incorrect value when behind mod_jk

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41263>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41263

           Summary: servletRequest.getRemotePort() returns incorrect value
                    when behind mod_jk
           Product: Tomcat 5
           Version: 5.5.20
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Native:JK
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: clamprecht@gmail.com


Access the following short test JSP running on a tomcat behind mod_jk and Apache:


<% out.println("Your IP is "+request.getRemoteAddr()+", your port is
"+request.getRemotePort()); %>


It returns either 0 or -1 for the remote port.  It seems to return 0 the first
time, and -1 for any subsequent request which is on the same underlying
keepalive connection.  

The desired behaviour would be that it returns the actual remote port that the
client connected from (on the client's machine), when available.  In other
words, it should behave the same as when you access the JSP through tomcat
directly through an HTTP connector (via port 8080 on a default tomcat install,
for instance).

I understand this information will not always be available, for instance, when
running behind a proxy.  But in the case of running behind mod_jk, shouldn't
this information be available, since the remote IP number is already available?

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 41263] - servletRequest.getRemotePort() returns incorrect value when behind mod_jk

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41263>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41263


rainer.jung@kippdata.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |LATER




------- Additional Comments From rainer.jung@kippdata.de  2008-01-03 05:54 -------
This needs a protocol extension for AJP13 (or whatever the version number will
then be).
Would be nice to also build in an easier protocol extensibility.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 41263] - servletRequest.getRemotePort() returns incorrect value when behind mod_jk

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41263>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41263


rainer.jung@kippdata.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|NEW                         |ASSIGNED




------- Additional Comments From rainer.jung@kippdata.de  2006-12-30 06:04 -------
Unfortunately the remote port is not part of the information passed along via
the ajp13 protocol. On the page

http://tomcat.apache.org/connectors-doc/ajp/ajpv13a.html

you can find under the heading "Request Packet Structure":

AJP13_FORWARD_REQUEST :=
    prefix_code      (byte) 0x02 = JK_AJP13_FORWARD_REQUEST
    method           (byte)
    protocol         (string)
    req_uri          (string)
    remote_addr      (string)
    remote_host      (string)
    server_name      (string)
    server_port      (integer)
    is_ssl           (boolean)
    num_headers      (integer)
    request_headers *(req_header_name req_header_value)
    attributes      *(attribut_name attribute_value)
    request_terminator (byte) OxFF

So I'm marking this as an enhancement request.
It's unclear though, if and when we will resolve this.
Thanks for the report.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 41263] - servletRequest.getRemotePort() returns incorrect value when behind mod_jk

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41263>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41263





------- Additional Comments From rainer.jung@kippdata.de  2006-12-30 06:12 -------
Implementation hint: if we want to stay compatible with ajp13 we could use
another request attribute (in the ajp13 sense, e.g. SC_A_REMOTE_PORT = 14).
Unknown attributes are ignored on the tomcat side.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 41263] - servletRequest.getRemotePort() returns incorrect value when behind mod_jk

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41263>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41263





------- Additional Comments From rainer.jung@kippdata.de  2006-12-30 09:43 -------
Unfortunately ignoring unknown attributes does not really happen. It's only what
the code comments claim to happen.

Instead unknown bytes are simply dropped, but if we introduce a new attribute
with a new indicator byte, the indicator gets dropped, but one of the following
length or data bytes might coincidently by equal to another indicator byte and
then everything breaks.

I tested by adding a new attribute server_addr, and the length of the addr
string was 12=oc. The decoder dropped the new indicator byte 0e but then found
the length byte 0c and assumed this to be equal to the SECRET indicator byte...

No easy way of adding new attributes :(

remotePort and LocalAddr have been forgotten (they were added in Servlet Spec
2.4) (resp. were dropped to not break the AJP13 protocol). We can easily get
both from Apache and IIS, but we first have to find a way to transmit them via
AJP13.


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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