Fastly Compute
This document describes integrating with the Spec Platform through a Fastly worker.
Prerequisites
Ensure your development environment meets the following requirements:
Node.js installed.
Node Package Manager (npm) or yarn.
An existing Fastly account is configured to handle your application’s traffic.
Fastly Compute CLI installed locally.
The Spec Worker Library.
If this is your first Worker, then please use the example code.
If your workers already have functionality, Spec's Product Success will help merge the Spec components into your Worker.
Check out the configuration options for the Spec Platform in Config.
Instructions
Configure the Worker
Create a new Fastly Compute project, or open an existing project.
Install the Spec Proxy Fastly Worker Package
npm i –save @specprotected/spec-proxy-fastly-worker
Open the
index.js
fileIf this is your first worker, Spec recommends using the example code for your Worker.
If you have existing workers, Spec's Product Success will help merge the Spec components into your Worker.
Run
fastly compute build
to compile the JavaScript to a WASM binary.
Configuring Fastly Compute
Log in to Fastly: After installing the Fastly CLI, log into your Fastly account. Navigate to the “Compute” section and select “Create Compute Service”.
Configure the Compute Service:
Enter the domain for the traffic that Spec will be protecting.
Set up two "Host origin" backends:
Application Server Origin
Spec Proxy URL (spec-internal): This URL will be provided by Spec. Its prefix will match the domain being protected.
Set the "Override Host" value to the Host address (likely the same for both backends).
Generate an API Token:
Create an API token for the Fastly CLI authentication.
Ensure the token has global scope access and set its expiration to conform to your compliance requirements.
Authenticate the Fastly CLI:
Run
fastly profile create
in your terminal.Enter your API key when prompted. This stores your Fastly API key in a configuration file for future commands, avoiding the need to provide the token with each command.
Deploy the Project to Fastly Compute:
After saving your configuration changes, publish the project to a Fastly Compute service by running
fastly compute deploy
in your terminal.
Once these steps are completed, the Spec Fastly Compute Service will be live!
Fastly Worker Code
Spec provides an integration library for Fastly Workers, which is hosted on NPM as a public TypeScript package. This library can be integrated into your current Fastly compute implementation, or can be added to a fresh configuration.
Example Fastly Worker Code
Check Edge Workers page for config options
Last updated