2

I have multiple remote systems that need to determine their public IPs, and I would like to use an internet-facing server running httpd 2.2 to return their remote addresses to them.

While this would be trivial if the httpd server was running PHP or similar, I would like to avoid needing extra server-side processing if httpd and its modules can be configured to get this information.

Is there some way to configure httpd to return the remote address? Maybe have a special URL that gets rewritten somehow? If it matters, the remote systems are running linux and would likely use wget which could print the information from the headers.

1
  • It is not possible to do so with Javascript, so you can create your own handler, or implement a higher level language, either client or serverside. some options for a wide variety of platforms here: javascript.about.com/library/blip.htm Commented Jun 10, 2014 at 14:18

1 Answer 1

2

Interesting question. I don't think Apache can do anything with the content of the document without using a server-side scripting language, but you should be able to modify the HTTP headers to contain the data you need.

An example:

<VirtualHost *:80>
  ServerName get-remote-host.int.mtak.nl

  SetEnvIf Remote_Host "(.*)" var1=$1
  Header set X-RemoteHost %{var1}e
</VirtualHost>

This will put an extra header in the response HTTP headers. If you get the headers of this request with curl -I get-remote-host.int.mtak.nl you get the IP of the client:

mtak@frisbee:~$ curl -I get-remote-host.int.mtak.nl
HTTP/1.1 200 OK
[...]
X-RemoteHost: 10.100.1.2
Content-Type: text/html
1
  • Excellent answer, this worked exactly as expected. Thanks! Commented Jun 10, 2014 at 14:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .