How to get HTTP client IP address?

Asked by Lucian Bazoi on 2011-02-23


   Is it possible, from the eCAP module, to retrieve the IP and maybe MAC address of the client making a GET or a Post Request and the time of the request? How can I do this?

Thank you.

Question information

English Edit question
eCAP Edit question
No assignee Edit question
Last query:
Last reply:
Alex Rousskov (rousskov) said : #1

Using libecap v0.2.0, it may be possible to retrieve the client IP address by querying host transaction for the option named metaClientIp. See libecap::host::Xaction::option() and visitEachOption() APIs.

Please note that supplying client IP is an optional feature and not all host applications will support it. FWIW, Squid does support it (but you need Squid version that supports libecap v0.2.0; see libecap announcement).

I do not know of any host application that supports sharing MAC addresses with adaptation services, and ICAP does not have a "standard" header for sharing that information either. Nevertheless, it is possible to add such support using the same libecap::host::Xaction::option() and visitEachOption() interface.

Alex Rousskov (rousskov) said : #2

Converted this to an FAQ:
FAQ #1516: “How to get the HTTP client IP address?”.

Alex Rousskov (rousskov) said : #3

As for the time of the request, there is no API for that, but perhaps it should be added. Meanwhile, you can use the current time in REQMOD and pass that time to RESPMOD using HTTP or meta-header if needed.

Can you help with this problem?

Provide an answer of your own, or ask Lucian Bazoi for more information if necessary.

To post a message you must log in.