/Documentation

How to use same origin through Fastly

Updated Oct 23, 2026

Before you begin

Setup guide

1. Create a host for your Fastly service

Create a host for your Fastly service
Create a host

2. Create a request condition for the same origin path

3. Create the VCL snippets that trim the path prefix

Create the VCL snippets that trim the path prefix
if (req.url.path ~ "^/metrics(?:/|\z)") { set bereq.url = regsub(bereq.url, "^/metrics/?", "/"); }

4. Create the request header that identifies the CDN

Create the request header that identifies the CDN

5. Create the request header that forwards the visitor IP

6. Create the request header that carries the original host 

7. Create the cache setting that disables caching for the same origin path

Create the cache setting that disables caching for the same origin path

8. Create the VCL snippet that bypasses the cache lookup

Create the VCL snippet that bypasses the cache lookup
if (req.url.path ~ "^/metrics(?:/|\z)") { set req.hash_always_miss = true; set req.hash_ignore_busy = true; }

9. Activate the service version

Activate the service version

Custom Loader

Custom Loader setup

Testing your same origin setup

Testing your same origin setup
Entering the path under Server container URLs
preview opens at the same-origin path
incoming page_view request from your website’s real domain

Was this article helpful?

Comments

Can’t find what you are looking for?