Get client IP with Header add in Apache2

9,496

In mod_headers to expand a variable the syntax is:

%{VARNAME}e : The contents of the environment variable VARNAME.

If you can use them most modules allow you to use/access the generic generic server variable names as listed in the manual.

REMOTE_ADDR The IP address of the remote host

So you end up with something along the lines of:

Header add X-Forwarded-For "%{REMOTE_ADDR}e"

But typically I would expect that the X-forwarded-For header gets set automatically: http://httpd.apache.org/docs/current/mod/mod_proxy.html#x-headers

Share:
9,496

Related videos on Youtube

EamonnMcElroy
Author by

EamonnMcElroy

Updated on September 18, 2022

Comments

  • EamonnMcElroy
    EamonnMcElroy over 1 year

    I am attempting to get the client IP in a HTTP header. I have seen a lot of references to getting this in Logs however i dont know how this translates to passing it as a header. I was going to use header add like below but dont know how to refer to client IP. Any help would be appreciated.

    Header add X-Forwarded-For "Client IP"