- English
- 日本語
Setting up redundant origin servers
Last updated 2018-10-02
Sometimes you want to set up two different origin servers, one as a primary and one as a backup in case the primary becomes unavailable. You can do this via the web interface or using custom VCL.
NOTE
Each Fastly service can be configured with up to five origin servers. Contact sales@fastly.com to enable more than five origin servers per service in your account.
Using the web interface
Set up redundant origins via the web interface using these steps.
- Log in to the Fastly web interface.
- From the Home page, select the appropriate service. You can use the search box to search by ID, name, or domain.
- Click Edit configuration and then select the option to clone the active version.
- Click Origins.
In the Health Checks area, define a health check and assign it to the primary origin server.
In the Hosts area, find your secondary origin server and click Attach a condition.
Click Create a new request condition.
Fill out the Create a new request condition fields as follows:
- In the Name field, enter the name of your request condition (for example,
Primary Unhealthy
). - In the Apply if field, enter
!req.backend.healthy
.
- In the Name field, enter the name of your request condition (for example,
Click Save and apply to. The Hosts area now displays the condition that must be met (Primary Unhealthy) in order for your secondary origin server to begin being used.
Once you've added the condition to your secondary origin server, the VCL generated by Fastly will reflect the new condition.
Preview the VCL, and confirm the following snippets appear in
vcl_recv
:# default conditionsset req.backend = F_primary;12345# Request Condition: primary unhealthy Prio: 10if (!req.backend.healthy) {set req.backend = F_secondary;}#end condition
Using custom VCL
Set up redundant origins with custom VCL using these steps.
In the Fastly web interface, define a health check and assign it to the primary origin server.
Copy the boilerplate VCL from our guide on mixing Fastly VCL with custom VCL, and paste it into a new file.
Replace the
vcl_recv
sub with:1234567891011sub vcl_recv {#FASTLY recvset req.backend = F_<primary_origin>;if (!req.backend.healthy) {set req.backend = F_<secondary_origin>;}if (req.method != "HEAD" && req.method != "GET" && req.method != "FASTLYPURGE") {return(pass);}return(lookup);}To find the exact backend names, view the generated VCL.
Upload your VCL file.
Do not use this form to send sensitive information. If you need assistance, contact support. This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.