0

My web application is running behind a proxy. Without ssl, I can get user's IP address simply by;

HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]

If I try the same thing with https then HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] returns nothing.

I should definitely use SSL, so what might cause this behaviour that I can get client's IP address only without https?

If you need more info please let me know.

mctuna
  • 809
  • 3
  • 19
  • 38
  • [This might help](https://stackoverflow.com/questions/45869956/https-version-of-serverhttp-x-forwarded-for-php) – ProgrammingLlama Oct 12 '18 at 07:57
  • So, what I understand from that comment, proxy inserts HTTP_X_FORWARDED_FOR for http and/or https depends on the configurations. Could that be related to a problem with my SSL certificate or maybe I need to add proxy's certificate into my trusted certificates folder in server? – mctuna Oct 12 '18 at 08:10
  • Essentially it depends on the configuration of the proxy server you're using, but the code igniter link provided also shows a variety of headers where this information could be provided. – ProgrammingLlama Oct 12 '18 at 08:11
  • I have tried those headers too 'HTTP_CLIENT_IP', 'HTTP_X_CLIENT_IP', 'HTTP_X_CLUSTER_CLIENT_IP' but no luck they are all empty – mctuna Oct 12 '18 at 08:17
  • What kind of proxy is it? Sounds to me like a configuration issue there, and has nothing to do with programming. – Lex Li Oct 12 '18 at 11:52

0 Answers0