1

I've got a httpd server sitting in front of tomcat. Both services are running on the same machine.

The machine has 2 IP address and I have domain names that are bound to the different IPs.

In the access logs for tomcat all the remote IP addresses show 127.0.0.1. I think this is because all tomcat knows is that the request originated from a client identifying itself with IP 127.0.0.1 and that this client is actually Apache.

Is there any way to get Apache to identify itself with the actual IP the domain name is bound to?

EDIT : A slightly longer story...

What I'm actually trying to do is determine whether requests are coming from our internal network or from the internet. We have 2 host names which resolve to 2 different IP addresses. One of these addresses is visible from the internet and one is not. My hope was that I could determine which IP/URL the user actually typed into their browser and use this to disable certain features we do not want accessible from outside the intranet.

Cheers, Peter

5
  • Hi and welcome on serverfault. Is apache the web server standing in front of tomcat? If so, are you using http or mod_jk for communication between apache and tomcat? Usually 127.0.0.1 appear because it's the ip adress of the client (ie apache). To get the good IP adress, you sometimes have to use X forwarded for http header.
    – user130370
    Nov 20 '13 at 10:50
  • I don't think X-Forwarded-For will help here, as it will show the client's source IP (i.e. the source IP of the client sending the request to apache). If I understand this correct, what he wants to see is the destination IP of the original request to apache.
    – etagenklo
    Nov 20 '13 at 10:56
  • etagenklo has it right. I'm actually trying to differentiate between users getting to the server from the internet and those on the intranet. I'll add more info to the question. Dec 2 '13 at 2:04
  • The hostname is always in the HTTP Host: header. Dec 2 '13 at 2:10
  • But can I rely on the host header from a security point of view? I think it might be easily spoofed. Dec 2 '13 at 2:48
1

Tomcat needs to support the X-Forwarded-For header (Apache does that with the rpaf module), and httpd (Apache, I guess) needs to set that header for you.

BTW, if using a proxy, aren't you better off using Nginx?

1
  • Thanks for the input. Tomcat does support the forwarded for header and Apache is setting it. I don't want to see the IP address of the machine before the Apache server. I want to see the IP address of that was used to reach the Apache server. Apache is currently just adding 127.0.0.1 to the X-Forwarded-For header, making it impossible for me to tell which url/ip was actually requested by the client. We have no choice which proxy to use, it is mandated by company policy. Dec 2 '13 at 2:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.