In order to activate Serverless Scripting, you will need to first make sure you have an active Stack and a Site for your domain created. You can either purchase Serverless Scripting on its own or within one of our other services, DNS, CDN, WAF, or Monitoring.
To learn more about Serverless Scripting please be sure to read our Serverless Scripting Overview.
Enable Serverless Scripting on a new Site
If you do not already have any existing services enabled for your domain, to use Serverless Scripting you'll first need to create a Site. A Site manages all of your StackPath services and can be configured to use Serverless Scripting and any additional StackPath services.
- Log into the StackPath Control Panel and select an active Stack
- Select Sites in the left hand navigation bar
- Select Create Site
- Select Serverless Scripting, enter your domain and select Continue. Please note that the additional cost of $10/month is per Stack, all Sites within the same Stack will have Serverless Scripting available at no additional cost.
- Enter your Origin IP address or Hostname and select Continue
Your StackPath Serverless Scripting service is now enabled.
Enable Serverless Scripting on an existing Site
If you already have a Site for your domain, you can easily enable the Serverless Scripting service. Please note that activating this service will apply to your entire Stack (this means all of your Sites within this Stack can use the Serverless Scripting at no additional cost).
- Navigate to the desired Site and select the Serverless Scripting tab. Select Continue to enable Serverless Scripting
- A dialogue will open to confirm you would like to add the service, select Confirm
- You will now see the Serverless Scripting overview which shows the statistics for all scripts on the specific Site you're looking at. You will also see a list of existing scripts and an "Add Script" button that will allow you to create your first script.
Create your first Script
Now that we have the Serverless Scripting enabled, let's create your first script. Simply click the Add Script button above and you will be taken to our easy to use Code Editor.
That's it! Once you click Create Script your script will be deployed to the Edge within 2 seconds. You will then be able to access your script using the route you provided. In the example above, it would be found at http(s)://yourdomain.com/demo-script or you can also test your scripts using the Edge Address for your Site.
Each script will be restricted to the following limits:
5ms CPU Execution Time
15s Wall Time
If you require more CPU/RAM for your script(s), please contact Sales and we'll be happy to discuss increasing that for your account.
Here are some examples of scripts you can create with the Serverless Scripting:
- Static response
- Response Body modification
- IP Firewall at the Edge
- wp-login protection
- Robots.txt response
- Add headers to response