0

I have created a web app through azure that entirely depends on a users location to give them the correct data e.t.c. It's an app that recommends places to go locally.

I'm using azure, cloudflare and codeigniter as the frame work.

I'm really getting stressed out, as when i'm home, i'm getting the right location, but the second i go on my website anywhere else, it never gets the accurate information.

When cheking the header $_SERVER['HTTP_CF_CONNECTING_IP']; i seem to be getting an ipv6 address, when i go to ipdata.co, their site loads my ipv4 address which gives exact accurate information. But when i enter the address from $_SERVER['HTTP_CF_CONNECTING_IP']; it gives me city null and every other option as null

does anyone have any suggestions on how to get the users IPV4 address through cloudflare and azure?

Or any suggestions on other ways to do this? It's prolonging the launch of my website.

I am pretty new to understand geo-location and ip addresses and all that, so please bare that in mind.

Thanks

1 Answers1

0

The reason that you are getting IPV4 address from your home and IPv6 from somewhere else as by default, Cloudflare provides free IPv6 support to all domains without requiring additional configuration or hardware. If your origin web server is not compatible with IPv6, Cloudflare allows toggling IPv6 Compatibility to Off. You can disable the IPV6 Compatibility to Off from cloudflare.

Reference: https://support.cloudflare.com/hc/en-us/articles/229666767

Cloudflare put into this header whatever the connecting client IP is, so they really have little control over what the user-agent decides to do.

Also check if your network has ‘good’ IPv6 connectivity, or are you getting sub-optimal routing compared to IPv4.

Check this link for additional reference.

http://www.webhostingtalk.com/showthread.php?t=1692173

Mohit Verma
  • 5,140
  • 2
  • 12
  • 27
  • 1
    Disabling ipv6 support for the website really is a hacky workaround, as ipv6 only networks are more and more common (they can be augmented with an ipv4 proxy for every user, but this covers a big area). – Ferrybig Sep 23 '19 at 06:02
  • Yes, I agree. other way we can use different server variable to get User Country. It is available in Cloudflare. – Mohit Verma Sep 23 '19 at 06:04