Movatterモバイル変換


[0]ホーム

URL:


  1. Home
  2. Reference documentation
  3. VCL reference
  4. Variables in VCL
  5. Geolocation

client.geo.ip_override

STRING, can be read andset, but notunset.

Available inall subroutines.

Override the IP address for geolocation data. The default is to useclient.ip as the source for geolocation.

On services that haveshielding enabled, the value ofclient.ip may be the address of another Fastly data center rather than the address of the end user. To access the end-user's geolocation data while on a shield server (which can be determined using thefastly.ff.visits_this_service variable), override the IP address usingclient.geo.ip_override.

When Fastly sees a request for the first time, we set theFastly-Client-IP header to the value ofclient.ip. This value is not updated by upstream Fastly servers, which makes it useful for this purpose:

if (fastly.ff.visits_this_service>0) {
setclient.geo.ip_override=req.http.Fastly-Client-IP;
}

Invalid addresses

It is possible to setclient.geo.ip_override to an invalid IP address

setclient.geo.ip_override="xxx";

in which case the various geolocation variables present values to indicate aninvalid region.STRING variables are set to the empty string,FLOATvariables are set to 999.0, andINTEGER variables are set to 0.

Try it out

client.geo.ip_override is used in the following code examples. Examples apply VCL to real-world use cases and can be deployed as they are, or adapted for your own service. See thefull list of code examples for more inspiration.

Click RUN on a sample below to provision a Fastly service, execute the code on Fastly, and see how the function behaves.

Geo-IP API at the edge

Create an API endpoint for fetching geolocation data for the requesting browser, implemented 100% at the edge. The response should show your current approximate location, but no requests to any origin servers.

Comprehensive logging

Fastly offers a myriad of different variables that you can log. See and test a large collection here.


[8]ページ先頭

©2009-2025 Movatter.jp