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 approach using an edge hosted solution to minimize the round trip time from the proxy to Amplitude.
Create a distribution
Follow these steps to create a new CloudFront distribution to proxy requests to Amplitude Experiment's evaluation servers. Any configuration field not explicitly mentioned in any steps can be left with the default value.
- In AWS, navigate to CloudFront and click Create distribution.
- In the Origin domain field, enter
api.lab.amplitude.comfor the US data center orapi.lab.eu.amplitude.comfor the EU data center. - In the Default cache behavior section, select
GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETEas the Allowed HTTP methods andOPTIONSas the Cache HTTP methods value. Cache HTTP methods appears when you select the Allowed HTTP methods value. - In the Cache key and origin requests section, select the
CachingDisabledcache policy, theAllViewExceptHostHeaderorigin request policy, and theCORS-with-preflight-and-SecurityHeadersPolicyresponse headers policy. The above selections require that you choose Cache policy and origin request policy (recommended) rather than Legacy cache settings. - In the Web Application Firewall (WAF) section, select Do not enable security protections.
- Click Create distribution.
Testing the distribution
Test the new distribution with curl request. To find the distribution domain name, select the new distribution from the list in CloudFront, copy the subdomain, and replace the SUBDOMAIN in the following curl. Then replace APIKEY with your deployment or project API key to authorize the request.
Successful requests return a 200 response.
curl -i 'https://SUBDOMAIN.cloudfront.net/v1/vardata' -H 'Authorization: Api-Key APIKEY'
Was this helpful?