Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 6
    warning, hackers can easily spoof the ip by sending fake X-FORWARDED-FOR: fakeip HTTP headers Commented Nov 2, 2019 at 15:06
  • Ofcourse, but if you use NGINX, clientIP is usually on "HTTP_X_FORWARDED_FOR" Commented Dec 14, 2020 at 12:17
  • 5
    This may not work as you expect: 1. all headers here allow the use of commas and/or semicolons, so you have to tokenize the string (ie, strtok($k, ';,')); 2. HTTP_X_FORWARDED does not exist; 3. The usage of HTTP_FORWARDED here (standardized) will always fail the filter_var test because it uses it's own syntax (ie, for=1.1.1.1;by=1.1.1.0). Commented Jan 18, 2021 at 19:50