On this page

Proxy requests to Experiment with AWS Cloudfront

Set up a reverse proxy to circumvent domain blocking in particular regions or by certain extensions and DNS servers. Because experiment APIs are latency sensitive, Amplitude recommends an edge-hosted solution to minimize round-trip time from the proxy to Amplitude.

Create a distribution

Follow these steps to create a new CloudFront distribution that proxies requests to Amplitude Experiment's evaluation servers. Leave any configuration field not mentioned in the steps at its default value.

  1. In AWS, go to CloudFront and select Create distribution.
  2. In the Origin domain field, enter api.lab.amplitude.com for the US data center or api.lab.eu.amplitude.com for the EU data center.
  3. In the Default cache behavior section, select GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE for Allowed HTTP methods and OPTIONS for Cache HTTP methods. The Cache HTTP methods field appears after you select an Allowed HTTP methods value.
  4. In the Cache key and origin requests section, select the CachingDisabled cache policy, the AllViewExceptHostHeader origin request policy, and the CORS-with-preflight-and-SecurityHeadersPolicy response headers policy. These selections require that you choose Cache policy and origin request policy (recommended) rather than Legacy cache settings.
  5. In the Web Application Firewall (WAF) section, select Do not enable security protections.
  6. Select Create distribution.

Test the distribution

Test the new distribution with a curl request. To find the distribution domain name, select the new distribution from the list in CloudFront and copy the subdomain. Replace SUBDOMAIN in the following command with that subdomain. Replace APIKEY with your deployment or project API key to authorize the request.

Successful requests return a 200 response.

bash
curl -i 'https://SUBDOMAIN.cloudfront.net/v1/vardata' -H 'Authorization: Api-Key APIKEY'

Was this helpful?