Bug 46082 - AJP HttpServletRequest.getLocalAddr() returns null when using the AJP Connector
Summary: AJP HttpServletRequest.getLocalAddr() returns null when using the AJP Connector
Status: RESOLVED WONTFIX
Alias: None
Product: Tomcat 6
Classification: Unclassified
Component: Connectors (show other bugs)
Version: 6.0.14
Hardware: PC Windows XP
: P1 blocker (vote)
Target Milestone: default
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-24 08:27 UTC by Peter Pichler
Modified: 2008-10-27 14:38 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Pichler 2008-10-24 08:27:50 UTC
I saw this problem in serveral different installations... using mod_jk as well as mod_proxy... Currently I am analysing an installation with an apache 1.3.41 using mod_jk (1.2.23).

request.getLocalAddr() returns null... 
request.getLocalPort() returns 447

447 is the used apache https port.

The ServletSpec is not very concrete how to answer this... but returning null is a bug definitly...

Solution Approaches
1.) Idealy getLocalAddr() should return the IP Address of the network interface used to reach apache...

2.) From my point of view it would be also ok, when returning IP and Port(!!!!) over which the AJP connector have been reached... 

3.) If both is not possible it would be great to have an additional configuration setting for the AJP connector.. eg request.LocalAddr and request.LocalPort... This shuld be easy to implement.
Comment 1 Mark Thomas 2008-10-27 14:38:27 UTC
The AJP protocol only passes the web server host name and port. It does not pass the IP address. Therefore, getLocalName() will return whatever is passed via AJP but getLocalAddr() will always return null.

Whilst getLocalAddr() could be modified to return the IP address Tomcat is listening on for AJP connections, I don't like the inconsistency that would generate when compared to getLocalName() and getLocalPort().