[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-30 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

--- Comment #19 from Rainer Jung  ---
(In reply to Eugene Chung (TmaxSoft) from comment #18)
> I'm a bit confused with the definition of getLocalXXX() APIs.
> Should they return the web server(intermediary in view of WAS)'s information?

I haven't checked the Spec but I don't it will clarify the behavior for that
situation.

One of the major ideas behind the AJP protocol is to transport the
communication data, that the intermediary saw, to the backend and let the
application see that information as if the backend was placed at the position
of the intermediary. One goal is to make sure, that any self-referential URL
the application creates will actually point to the intermediary and not the the
backend.

That's why we have chosen to return the local IP of the intermediary from the
AJP connector.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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



[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-30 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

--- Comment #18 from Eugene Chung (TmaxSoft)  ---
I'm a bit confused with the definition of getLocalXXX() APIs.
Should they return the web server(intermediary in view of WAS)'s information?

-- 
You are receiving this mail because:
You are the assignee for the bug.

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



[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-29 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

Mark Thomas  changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
 Resolution|--- |FIXED

--- Comment #17 from Mark Thomas  ---
Fixed in 6.0.x for 6.0.42 onwards.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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



[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-13 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

--- Comment #16 from Rainer Jung  ---
Forwarding the local IP address as the custom request attribute will also be
part of mod_proxy_ajp in the Apache web server 2.4.10. Adding it to the next
release of Apache httpd 2.2 has been proposed as well.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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



[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-10 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

Rainer Jung  changed:

   What|Removed |Added

  Component|Connectors  |Connectors
Version|trunk   |6.0.41
Product|Tomcat 8|Tomcat 6

-- 
You are receiving this mail because:
You are the assignee for the bug.

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



[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-10 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

--- Comment #15 from Rainer Jung  ---
Test looked good.
Ported by to TC 7 in r1609606 and proposed for TC 6.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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



[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-10 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

--- Comment #14 from Rainer Jung  ---
I added support for the new attribute to TC 8 in r1609593.
Needs some more testing before porting back to TC7 an probably 6.

A full test needs a dev build of mod_jk r1609589 or later.

Alternatively one can try in Apache:

SetEnvIf Server_Addr "(.*)" AJP_LOCAL_ADDR=$1
JkEnvVar AJP_LOCAL_ADDR

Which for current releases of mod_jk would send a request attribute named
AJP_LOCAL_ADDR with its value set to the value of the Apache internal variable
SERVER_ADDR which in turn contains the local IP address of Apache.

Starting with mod_jk 1.2.41 the attribute will be set without explicit
configuration.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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



[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-10 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

Rainer Jung  changed:

   What|Removed |Added

  Component|mod_jk  |Connectors
Version|1.2.40  |trunk
Product|Tomcat Connectors   |Tomcat 8
   Target Milestone|--- |

--- Comment #13 from Rainer Jung  ---
Implemented new request attribute "AJP_LOCAL_ADDR" in mod_jk r1609589.

Will be part of version 1.2.41.

Assigning issue back to Tomcat for implementing the use of the new attribute.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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



[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-07 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

Mark Thomas  changed:

   What|Removed |Added

  Component|Servlet & JSP API   |mod_jk
Version|7.0.53  |1.2.40
Product|Tomcat 7|Tomcat Connectors

--- Comment #12 from Mark Thomas  ---
OK. Looks like the information is available in the httpd internals but not
(obviously) via config. Therefore, if mod_jk implements a new request atribute
to pass this information, Tomcat can use it for getLocalAddr(). Moving this to
mod_jk to get that implemented.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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



[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-07 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

--- Comment #11 from Konstantin Kolinko  ---
As examples:
Implementation of custom "JK_LB_ACTIVATION" request attribute: r1078846
Implementation of custom "AJP_REMOTE_PORT" request attribute: r756926 r757223

Those are the only custom header names in native/common/jk_ajp_common.h of
mod_jk, so I think those are the only examples.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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



[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-07 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

--- Comment #10 from Konstantin Kolinko  ---
There is such directive as
 JkOptions  +ForwardLocalAddress

http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html

Commit that implemented it:
http://marc.info/?l=tomcat-dev&m=111545377731908&w=2

>> r->connection->local_ip

-- 
You are receiving this mail because:
You are the assignee for the bug.

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



[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-07 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

--- Comment #9 from Konstantin Kolinko  ---
(In reply to Mark Thomas from comment #7)
> I've just taken a look at the httpd docs as well and I don't see any way of
> obtaining the IP address of the interface that the request was received on.

Looking at CustomLog formats [1] it says that "%A" is "Local IP-address". Thus
there should be a way.

There is also such feature as IP-based virtual hosts. [2]


[1] http://httpd.apache.org/docs/2.4/mod/mod_log_config.html#formats
[2] http://httpd.apache.org/docs/2.4/vhosts/ip-based.html

-- 
You are receiving this mail because:
You are the assignee for the bug.

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




[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-07 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

--- Comment #8 from Mark Thomas  ---
Just re=read my previous comment and it isn't very clear.

My proposal is to leave 7.0.x and earlier unchanged and to change 8.0.x onwards
to return the empty string by default for getLocalAddr()

-- 
You are receiving this mail because:
You are the assignee for the bug.

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



[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-07 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

--- Comment #7 from Mark Thomas  ---
I've just taken a look at the httpd docs as well and I don't see any way of
obtaining the IP address of the interface that the request was received on.
That reduces the choices to:
a) returning null
b) return the hose name (current behaviour)
c) use DNS to get the IP address
d) return an empty string

If I was starting from a clean slate, I choose option a). However, given the
current behaviour that is likely to start triggering NPEs in applications. That
makes d) preferrable to a).

There are many cases where c) will not return the correct value. DNS
round-robin load-balancing being one. Therefore, I don't think this apporach
should be used.

So that leaves b) or d) as the possible options in this case. I don't think we
should change it for 7.0.x or earlier but we could change it in 8.0x onwards.

I leave it a few days before doing anything to give folks a chance to comment.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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



[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-07 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

--- Comment #6 from Christopher Schultz  ---
Technically, this shouldn't require a change to the AJP protocol, as arbitrary
HTTP headers can be sent just by modifying the configuration.

Unfortunately, the CGI spec does not specify anything like "localAddr"... the
closest thing available is SERVER_NAME which ... comes from the client's "Host"
header. I suspect this is what is being used for getLocalAddr, here.

Reading a bit about httpd's capabilities, I'm not sure it's actually possible
to get the IP address of the server interface that accepted the request from
the client. If the address *can* be obtained, sending it via an HTTP header and
using something like the RemoteIpValve would probably work.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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



[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-06 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

--- Comment #5 from Mark Thomas  ---
All AJP connectors behave this way and have done since getLocalAddr() was added
in Servlet 2.4.

The problem is that the AJP protocol passes the remoteAddr, remoteHost,
localName and localPort but *NOT* the localAddr.

localAddr should be the IP address the client used to contact the server and
this simply is not available - hence why the host name was used.

Possible solutions include modifying the AJP protocol but this is non-trivial.

A simple work-around would be to have the reverse proxy add a custom header
with the localAddr information and then have a Valve / Filter read that header
value and then present it to the application.

I'm leaning towards resolving this as WONTFIX.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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



[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-04 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

--- Comment #4 from Konstantin Preißer  ---
Hi,

I can confirm that this problem happens with Tomcat 8.0.9 when using AJP NIO
connector (I used the ISAPI Redirector with IIS).
In this case, request.getLocalAddr() returns the name of the "Host" header
instead of an IP address, e.g. "localhost".

If using the HTTP NIO connector, the problem does not occur;
request.getLocalAddr() will return an IP address in this case, e.g.
"0:0:0:0:0:0:0:1".

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-04 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

Palle Girgensohn  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|WORKSFORME  |---

--- Comment #3 from Palle Girgensohn  ---
I do get 0:0:0:0:0:0:0:1 when accessing http://localhost:8080/ now, that might
just have been a mistake.

It seems that the problem is with the AJP Connector?

$ cat foo.jsp 
<%= request.getLocalAddr() %>
$ curl  http://localhost/foo.jsp
localhost
$ curl -k https://localhost/foo.jsp
localhost

This holds true for tomcat 7.0.54 on FreeBSD and Mac OS X.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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



[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-07-04 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

Mark Thomas  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WORKSFORME

--- Comment #2 from Mark Thomas  ---
Tested with 7.0.x and 8.0.x on OSX and request.getLocalAddr() returns an IP
address when accessed via http://localhost:8080/...

-- 
You are receiving this mail because:
You are the assignee for the bug.

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



[Bug 56661] ServletRequest#getLocalAddr() returns the hostname, not the IP address

2014-06-24 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=56661

--- Comment #1 from Christopher Schultz  ---
Not yet verified (by me), but the Servlet API Javadoc pretty clearly says this
method should return an IP address (and not a hostname).

-- 
You are receiving this mail because:
You are the assignee for the bug.

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