apibackendapi-gatewaygoogle-geolocation

Moving frontend Google API to backend


I'm using Google Geolocation API on my website. I wanted to restrict my API key, but HTTP referrer restriction for Geolocation API is not allowed (only IP restriction).

My website is hosted on cluster of servers, and in front of them is load balancer, and in front of load balancer is CDN.

I tried adding my CDN IPs, but as I can see API call is made from Client IP not my CDN API, so it didn't work.

Can I move my google geolocation API call to my server with a microservice? So that I can use IP referrer restriction?

Based on my server structure, will the call be made from CDN IPs?


Solution

  • Can I move my google geolocation API call to my server with a microservice? So that I can use IP referrer restriction?

    Yes, a sample request might look like

    {
      "considerIp": "false",
      "wifiAccessPoints": [
        {
          "macAddress": "84:d4:7e:09:a5:f1",
          "signalStrength": -43,
          "signalToNoiseRatio": 0
        },
        {
          "macAddress": "44:48:c1:a6:f3:d0",
          "signalStrength": -55,
          "signalToNoiseRatio": 0
        }
      ]
    }
    

    where considerIp is false.

    Based on my server structure, will the call be made from CDN IPs?

    This doesn't really make sense. The IP will be that of the server or proxy.