khromov / wp-wpml-geoip-browser-language-redirect

GeoIP Redirector for WPML (WordPress)
GNU General Public License v2.0
46 stars 17 forks source link

Added fallback if key HTTP_X_FORWARDED_FOR not exist. #31

Closed MakarandMane closed 4 years ago

MakarandMane commented 6 years ago

Recently I came to know while using Chrome on android mobile with data saver on. Google proxy server is not adding key HTTP_X_FORWARDED_FOR. I found real IP using HTTP_FORWARDED.

khromov commented 6 years ago

@MakarandMane Thanks for the patch. Since it appears that the Forwarded header may contain additional information, maybe a regex like .*for=(.*?);.* would be better for picking out the IP from the capture group? According to MDN the format is: Forwarded: by=<identifier>; for=<identifier>; host=<host>; proto=<http|https>

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded

khromov commented 4 years ago

Closing as author never addressed my comment.

MakarandMane commented 4 years ago

@khromov I had tried you suggestion but later did not finalise code. So didnt updated here.