SERA integration on CloudFront¶
Kindly follow the below steps to setup the routing of bot traffic to SERA.
Steps¶
-
Creating a function¶
-
Open Cloudfront Dashboard, and select
Functions
menu on the left side
-
Click on
Create function
-
Fill the details as shown below :
In
Name
:Runtime
, selectCloudfront-js-2.0
And then Click onCreate function
-
Select
Build
tab
Copy the code from this js file, and paste it in the textarea.
Put the SERA token shared with you inSERA_TOKEN
variable value
Keep required value uncommented forBOTS
variable based on testing/live phase
Click onSave
-
Select
Test
tab
Leave everything unchanged, and click onTest function
. You should then see a success message.
-
Select
Publish
tab
Click onPublish function
-
-
Associating the function to Behavior¶
-
Select
Distributions menu
on Left
-
Click on the respective distribution from the list
SelectBehaviors
tab
-
Select respective behavior, and
Edit
it
-
Go to bottom
Function associations
section at bottom
-
In
Viewer request
section, selectCloudfront Functions
as Function type
-
Select the created function (
n7-sera-routing
) inFunction ARN/Name
dropdown
-
Save
-
-
Testing and Refinement¶
- Keep refining the logic by adjusting user-agent list, and SERA exclusion-patterns as needed.
- Test thoroughly:
- WPT and GTMetrix will automatically receive the response from SERA due to the routing rule set above.
- Steps to validate page using WPT
- To check the SERA rendered page on browser, you can use some browser extension (like Simple modify headers) to manipulate the browser user-agent. If in testing phase, use these user-agent values: For desktop: For mobile: If SERA is live, you can use these actual bot user-agent values: For desktop: For mobile:
- WPT and GTMetrix will automatically receive the response from SERA due to the routing rule set above.
- On go-live day, set the user-agent condition regex to actual bot user-agent values. Additionally, ensure that your condition is case-insensitive.