Fastly
This guide explains how to configure Fastly Compute@Edge to create a reverse proxy that serves the Didomi Consent notice from your own domain and a subdomain. Two implementation options are available based on your requirements.
Choose Your Implementation
Option A: Use a subdomain
To implement a reverse proxy on a subdomain, you will first create a lightweight Rust application compiled to WebAssembly, then configure Fastly backends and deploy the WASM binary. This approach uses minimal edge processing with simple backend routing.

Customer Usage:
/api/*and/sdk/*paths directlyArchitecture: Fastly with minimal WASM processing
Implementation: Simple backend routing with lightweight Rust code
Option B: Use the main domain
To implement a reverse proxy on the main domain, you will first create a Rust application with URL transformation logic, then compile it to WebAssembly and deploy to Fastly Compute@Edge. The application handles /consent/* prefix removal and routes requests to appropriate Didomi backends.

Customer Usage:
/consent/*prefix for all CMP requestsArchitecture: Fastly Compute@Edge with full URL transformation
Implementation: URL transformation and advanced processing
Domain vs Subdomain Trade-offs
When implementing a reverse proxy for the Didomi SDK and its API events, you need to choose between using your main domain or a dedicated subdomain. This choice has important implications for Safari's cookie restrictions.
For more information, see this trade-off matrix to select the implementation that suits your requirements.
Implementation guide
Shared setup steps (both options)
Common prerequisites (Both options)
Fastly account with Compute@Edge enabled
Rust toolchain with WebAssembly support
fastlyCLI tool installed (installing and configuring Fastly CLI)Domain configured for Fastly service
Access to your domain's DNS configuration
Shared setup steps (both options)
Domain and DNS configuration
1. Domain setup in Fastly
Add domains
Log into Fastly Dashboard
Navigate to: Configure → Domains
Add Domains: Enter both
YOUR_DOMAIN_NAMEandwww.YOUR_DOMAIN_NAME
2. DNS configuration
For root domain (A record)
For subdomain (CNAME Record)
3. TLS Certificate configuration

Certificate subscription setup
Navigate to: TLS Configuration → Certificates
Create new subscription
Configure subscription:
Domains: Enter
YOUR_DOMAIN_NAME, www.YOUR_DOMAIN_NAME(comma-separated)Common Name:
YOUR_DOMAIN_NAMECertification Authority: Let's Encrypt
TLS Configuration:
HTTP/3 & TLS v1.3 + 0RTT (t.sni)
ACME challenge configuration
After submitting the certificate request, Fastly will provide an ACME challenge:
Create DNS CNAME record:
Verify DNS propagation:
Certificate validation: Fastly will automatically validate domain ownership and issue the certificate
Fastly service configuration
1. Create Fastly service
Create a new Compute@Edge service in Fastly dashboard or via CLI:
2. Configure backends (Both options use same backends)

In the Fastly dashboard, configure two backends:
Backend 1: Didomi SDK
Name:
didomi_sdkAddress:
sdk.privacy-center.orgPort:
443(HTTPS)Host Header:
sdk.privacy-center.orgOverride Host: Yes
Use SSL: Yes
SSL SNI Hostname:
sdk.privacy-center.orgSSL Certificate Hostname:
sdk.privacy-center.org
Backend 2: Didomi API
Name:
didomi_apiAddress:
api.privacy-center.orgPort:
443(HTTPS)Host Header:
api.privacy-center.orgOverride Host: Yes
Use SSL: Yes
SSL SNI Hostname:
api.privacy-center.orgSSL Certificate Hostname:
api.privacy-center.org
Option A: Use a subdomain
This option uses simple direct routing with minimal WASM code on a subdomain.
Step 1: Create fastly.toml
Step 2: Create Cargo.toml
Step 3: Create simple implementation (src/main_simplified.rs)
Step 4: Deploy option A
Step 5: Test option A
Option B: Use the main domain
This option includes URL transformation to handle /consent/* prefixes.
Prerequisites: Use the same backends and DNS setup as Option A above.
Step 1: Create fastly.toml for Option B
Step 2: Create Cargo.toml for Option B
3. Main implementation (src/main.rs)
Deployment steps
1. Build the application
2. Test locally
3. Deploy to Fastly
Configuration requirements
DNS configuration
Point your domain/subdomain to Fastly:
Create a CNAME record pointing to your Fastly service domain
Or configure A records to Fastly IP addresses
SSL/TLS setup
Upload SSL Certificate to Fastly (if using custom domain)
Enable TLS for both backends
Configure SNI for proper SSL handshake
Headers and caching
For SDK resources (/consent/*):
/consent/*):Cache TTL: 3600 seconds (1 hour)
Vary Header: Accept-Encoding, Accept-Language
CORS: Enabled for cross-origin requests
For API endpoints (/consent/api/*):
/consent/api/*):Cache TTL: 0 (no caching)
Cache-Control: no-cache, no-store, must-revalidate
CORS: Enabled with appropriate headers
After setting up your reverse proxy, update your Didomi SDK snippet to use your own domain instead of privacy-center.org. This ensures that the Didomi assets are served from your configured domain.
For more information, see the guide to serving Didomi assets from your domain.
Last updated