LOG IN SIGN UP
Documentation

Failover configuration

This guide describes how to configure a failover origin server. A failover (backup) server ensures you can maintain availability of your content if your primary server is not available.

Before you begin

Before you configure failover, keep in mind the following:

Configuring a failover origin server

Once you've confirmed health checks are configured, you must:

  1. Turn off automatic load balancing on both the primary origin server and the server that will become your failover.
  2. Create headers that configure both the primary and failover origin servers.
  3. Create a header condition that specifies exactly when to use the failover server.

Turn off automatic load balancing

To configure a failover origin server you must turn off automatic load balancing for both the server that will act as your primary origin server and the server that will become your failover origin server.

  1. Log in to the Fastly application.
  2. Click the configure tab (the wrench icon).
  3. Select the appropriate service from the Service menu.
  4. Click the blue Configure button.
  5. Click the Hosts pane from the list on the left.

    accessing the hosts pane so the backend settings can be edited

  6. In the Backends area, click the gear icon next to the name of the origin server you want to configure.

  7. Click Edit. The Edit Backend window appears.

    selecting no in the auto-load balancing menu of the Edit Backend window

  8. From the Auto Load Balance menu, select No.

  9. Click Update to apply the changes.

Configure the primary and failover origin servers

Once you've turned off automatic load balancing, create two new request headers, one each for your primary and failover servers.

  1. Click the Content pane from the list on the left.
  2. In the Headers area, click the New button to create the first request header. The New Header window appears.

    setting up a request header to set the primary origin server

  3. Fill out the New Header window as follows:

    • In the Name field, type a descriptive name for the header.
    • From the Type/Action menus, select Request and Set.
    • In the Destination field, type the name of the header that will be affected by the selected action.
    • In the Source field, type where the new content for the header comes from.
    • Leave the Ignore If Set and Priority controls at their default settings.
  4. Click Create to create the first header. A new header appears in the Headers area that sets the first server as the primary origin server.

  5. In the Headers area, click the New button to create a second request header. The New Header window appears.

    setting up a request header to set the default backend failover

  6. Fill out the New Header window as follows:

    • In the Name field, type a descriptive name for the header.
    • From the Type/Action menus, select Request and Set.
    • In the Destination field, type the name of the header that will be affected by the selected action.
    • In the Source field, type where the new content for the header comes from.
    • Leave the Ignore If Set control at the default setting.
    • In the Priority field, type a number at least one higher than the priority you set on the primary server's request header. For example, if you left the first header's priority set to the default, 10, you would set the second header's priority to 11 or higher.
  7. Click Create to create the second header. A new header appears in the Headers area that sets the second server as the failover for your primary origin server.

Specify when to use the failover server

Once you've configured your primary and failover servers, create an associated header condition that specifies exactly when the failover server should be used.

  1. In the Headers area, click the gear icon next to the new header you just created for the failover origin server, and select Request Conditions.
  2. Click the New button to create a new condition. The New Condition window appears.

    setting a request condition for unhealthy backends

  3. Fill out the New Condition window as follows:

    • In the Name field, type a descriptive name for the new condition (for example, Primary Down).
    • In the Apply If field, type the appropriate request condition that will be applied. For example, req.restarts > 0 || !req.backend.healthy would tell the system only to use the failover server if the number of restarts is more than 0 or the origin is unhealthy.
    • In the Priority field, type 11.
  4. Click Create to create the new condition for the header.

  5. Activate the new configuration for your service.