If you have a reverse proxy, cache, or content delivery network (CDN) in front of your application, you will want to bypass it when profiling with Blackfire.

We provide an example below to describe which headers are sent and required to pass through to your application (and the Blackfire Probe) in order for Blackfire to successfully profile your application.

If there is a reverse proxy such as Varnish or HA Proxy between your browser and the profiled website, you will probably want:

  • To serve a non-cached version from the reverse proxy;
  • To not remove the special HTTP headers injected by the browser extension;
  • To target a specific server behind the proxy.

Blackfire browser extension uses a unique HTTP header for its requests: X-Blackfire-Query.

You also need to be sure that the following HTTP response headers are preserved: X-Blackfire-Response and X-Blackfire-Error

Here's a varnish configuration sample:

acl profile {
   "x.y.z.w";
}

sub vcl_recv {
  if (req.http.X-Blackfire-Query && client.ip ~ profile) {
    if (req.esi_level > 0) {
        # ESI request should not be included in the profile.
        # Instead you should profile them separately, each one
        # in their dedicated profile.
        # Removing the Blackfire header avoids to trigger the profiling.
        # Not returning let it go trough your usual workflow as a regular
        # ESI request without distinction.
        unset req.http.X-Blackfire-Query;
    } else {
        return (pass);
    }
  }
}


Did this answer your question?