After adding a new CDN provider to your service, you may want to test it before routing production traffic to it.
You can do this by bypassing DNS resolution on your test machine using the hosts file. On Linux and macOS, this file is located at /etc/hosts.
This allows you to test the new CDN provider locally without impacting real users.
Test a New CDN Provider #
- Navigate to your service.
- In the sidebar, select CDN Providers.
- Copy the CNAME of the newly added provider and use the
digcommand to resolve it.
- For example:
dig d3ryv6809vaohj.cloudfront.net
- Copy the IP address returned by the command.
4. Edit the /etc/hosts file on your local machine. This may require administrator privileges. Add a new line at the end of the file containing the IP address from the previous step followed by your service domain.
- For example:
18.160.143.49 www.example.com
- Save the file and exit.
5. Once configured, requests to your service domain from your local machine will be directed to the new CDN provider. You can now test the provider before routing production traffic to it.
6. Once testing is complete, revert the changes made to /etc/hosts to restore regular DNS resolution.
Verifying the Response #
You can verify that your request is being served by the new CDN provider by checking the x-ioriver response header.
For example, the following curl command can be used to inspect the response:
curl -v https://www.example.com
A response served by Fastly will include:
< x-ioriver: Fastly