2

I use clearsilver library to write CGI. And before my Apache, I use Haproxy. I can output the real user ip in the apache log using:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{X-Forwarded-For}i\"" common

But I nearly test everything, for example: HTTP.XForwardedFor, HTTP_X_FORWARDED_FOR and so on to get the real ip from hdf, but none of them seems right. How can I get it? From which key?

PhilMY
  • 2,621
  • 21
  • 29
user1400047
  • 247
  • 2
  • 10

1 Answers1

2

Have you tried getenv("HTTP_X_FORWARDED_FOR")? Judging by cgi.c, clearsilver doesn't copy the X-Forwarded-For header, but you should still be able to pluck it out of the environment, where apache put it.

Community
  • 1
  • 1
Iain
  • 4,203
  • 23
  • 21