Skip to content

vanbenj/db-cloudflare-test

Repository files navigation

Planetscale Cloudflare IP allow list support

This is a simple cloudflare worker to demonstrate that Planetscale ip restrictions need to include ipv6 support

How to use:

  1. Create a cloudflare account (it's free)
  2. Checkout this code then run:
pnpm install
pnpm wrangler login
  1. Get the database url for your Planetscale databse and save it as a secret:
pnpm wrangler secret put DATABASE_URL
  1. Deploy the app:
pnpm deploy
  1. Open the preview url provided in your browser - you should see: Success - was able to connect and query the database

  2. Add a Planetscale ip restriction rule with allow list from https://www.cloudflare.com/ips/

    103.21.244.0/22, 103.22.200.0/22, 103.31.4.0/22, 104.16.0.0/13, 
    104.24.0.0/14, 108.162.192.0/18, 131.0.72.0/22, 141.101.64.0/18, 
    162.158.0.0/15, 172.64.0.0/13, 173.245.48.0/20, 188.114.96.0/20, 
    190.93.240.0/20, 197.234.240.0/22, 198.41.128.0/17
    
  3. Refresh you browser and you should see: Error - connection not allowed

PROBLEM SOLVED (Cloudflare should really update their docs)

Planetscale support did some testing and found this IP address is missing from the Cloudflare allow list:

104.16.0.0/12

Once that was added this app starts to work. The full IP allow list for Cloudflare should be:

103.21.244.0/22, 103.22.200.0/22, 103.31.4.0/22, 104.16.0.0/13, 
104.24.0.0/14, 108.162.192.0/18, 131.0.72.0/22, 141.101.64.0/18, 
162.158.0.0/15, 172.64.0.0/13, 173.245.48.0/20, 188.114.96.0/20, 
190.93.240.0/20, 197.234.240.0/22, 198.41.128.0/17,
104.16.0.0/12

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published