if (server.region ~ "(^EU-|^AF-|^South-Africa$)" && backend.F_origin_0.healthy) {
  set req.backend = F_origin_0; /* European origin */
  log "Selecting European origin as geographically closest";
} else if (server.region ~ "(^Asia-|^Asia$|^APAC$)" && backend.F_origin_1.healthy) {
  set req.backend = F_origin_1; /* Asian origin */
  log "Selecting Asian origin as geographically closest";
} else if (backend.F_origin_2.healthy) {
  set req.backend = F_origin_2; /* American origin */
  log "Selecting American origin as geographically closest";
} else {
  set req.backend = F_origin_0; /* Use European origin as fallback */
  log "Selecting European origin as fallback";
}