client.bot.name
STRING, read-only.
Available inall subroutines.
Where the client is identifying itself as a known bot, this variable is set to the name of the bot (e.g., "Googlebot") claiming to be making the request.
The User-Agent
header, which is used to infer the name of the bot, may be set arbitrarily in the request headers from a client. Some bots may therefore choose to send a User-Agent
header that identifies them as a different, better known bot in order to evade or intentionally trigger logic that is intended to apply to that kind of bot. In setting the value of client.bot.name
, Fastly makes no attempt to verify the claims being made by the requesting client.
However, it is possible to use other aspects about a HTTP request - in particular the network from which the client IP is allocated, in order to better verify the authenticity of a bot's identity. For example, a client legitimately claiming to be Googlebot will only ever make requests from Google's network, and you could write VCL code to validate this:
if (client.bot.name == "Googlebot" && client.as.name == "google llc") { # The client *claims* to be Googlebot and the client IP belongs to Google ...}
Fastly provides Geolocation data for IPs, including which autonomous system an IP is registered to. You can use this in conjunction with the client.bot.name
variable to confirm that the IP is in fact one of the IP ranges registered to Google: