tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johnny Kewl" <>
Subject Re: Tomcat - Apache: IP replacement
Date Tue, 03 Jul 2007 11:13:53 GMT
Hi Nino,

Just to make sure my memory served me correctly, I setup a test case for
Apache -> JK -> TC.... on a machine (XP SP2) with IPV6 enabled.
Apache, Browser and TC... are all on same machine to simulate your test.
Apache is not IPv6 enabled
The machines name is Animal.... ipv4 IPv6 2001:918:0:12:1::2
I have a simple webapp that returns the getRemoteAddr

Turns out I was close, but my memory is actually crap ;)
This is what happens...

==== Direct to TC  Local Browser===
http://localhost:8080/TestRemoteIp/   gives  Remote IP is 0:0:0:0:0:0:0:1
http://animal:8080/TestRemoteIp/   gives  Remote IP is 0:0:0:0:0:0:0:1
(See my memory sucks.... I remembered that as
This is different from IPv4.... normally that will return if 
I remember correctly ;)
So IPv6 seems to map it all to the loop back address   gives Remote IP is
Thank goodness ;)

http://[2001:918:0:12:1::2]:8080/TestRemoteIp/  gives Remote IP is 

=== Thru Apache Local Browser===
http://localhost/TestRemoteIp/  gives Remote IP is
It actually fixes it ;)
http://animal/TestRemoteIp/  gives Remote IP is
So with IPv6 the machine name is now mapping to loop back... on IPv4 it 
would be  gives Remote IP is

http://[2001:918:0:12:1::2]/TestRemoteIp/   FAILS expected because this 
apache is not IPv6 enabled

=== Thru Apache REMOTE machine Browser===
When Calling "Animal", or "".... always gives the correct IPV4 
address of remote machine (which is not IPv6 enabled)

So as you can see.... a few things are different on IPV6..... which I now 
believe you not on ;).... the you getting is just very strange
Even though the little differences will make developers pull their hair out 
;).... its definitely is working, even on IPv6 and the differences are only 
when testing from a local browser.

Just to make sure.... I downloaded Apache and Mod_JK again for the test....
Used Apache apache_2.2.4-win32-x86-no_ssl.msi

NOTICE THAT even though JK is now at version JK-1.2.23.... the binary file 
you download must match the version of Apache.
as you can see from the notes on this page

======= MOD_JK.conf ========

<IfModule !mod_jk.c>
  LoadModule jk_module "D:/DEV/Apache2.2.4/modules/"

JkWorkersFile conf/jk/
JkLogFile conf/jk/mod_jk.log

JkLogLevel info
#JkLogLevel debug

JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"

JkMount /TestRemoteIp/*  worker1

========== WORKERS.Properties ========





=============== Test JSP =================

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>TEST getRemoteAddr</title>

    <h1>TEST getRemoteAddr</h1>

String callerIP = request.getRemoteAddr();
    <p>Remote IP is <%=callerIP%></p>


I couldnt simulate what you getting.... can only suggest you download the 
stuff again... the above definitely works, and I'm guessing you got a bum 
file, or a mismatch between Apache and JK module......

Good Luck

----- Original Message ----- 
From: "Nino Ulsamer" <>
To: "Tomcat Users List" <>
Sent: Monday, July 02, 2007 5:43 PM
Subject: AW: Tomcat - Apache: IP replacement

thanks for your support so far.
I just played around with the settings some more and could find out more 
interesting stuff...

First of all, about our configuration: we have an Apache and Tomcat running 
on the same machine, with JK 1.2 in between. If I log requests in Apache, 
the IP address is correct. If I go directly to Tomcat (via port 8080), the 
IP is correct. But if I go through JK, the address gets changed to 
I checked the JK log file, and it logs the following before forwarding to 

[Mon Jul 02 17:28:36 2007] [0848:1240] [debug] mod_jk.c (604): Service 
protocol=HTTP/1.1 method=GET host=(null) addr= 
port=80 auth=(null) user=(null) raddr=

So even here, this strange is coming up.

One more intersting to notice. From the logfiles I saw that this whole 
problem started when we switched from JK 2 to JK 1.2 (which is supposed to 
be the newer version).

But we are using very basic settings of JK, according to the howto of the 
website. A single loadbalancer-worker, so nothing special.

Any hints???


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message