# Detect a restart triggered by a backend response status
# (this is triggered in DELIVER)
if (req.restarts == 0) {
  unset req.http.restart-for-custom-response;
} elsif (req.http.restart-for-custom-response) {
  if (req.http.restart-for-custom-response ~ "^4") {
    # A custom response could be a page you load from a static bucket
    # or other kind of alternative backend
    log "We're going to fetch and serve an error page from a static backend";
    set req.url = "/fastly-fiddle-examples/error-pages/error.html";
    set req.backend = F_origin_1;
    set req.http.Fastly-Force-Shield = "1";
    return (lookup);
  } else {  
    # Or could be a response generated entirely within your
    # edge code - for which, you need to trigger a VCL error.
    # (Use any status in the 6xx range for internal signalling in VCL)
    error 600;
  }
}