Network ports

HTTP: 80 8080 | No caching: 8880 2052 2082 2086 2095
HTTPS: 443 | No caching: 2053 2083 2087 2096 8443

Rules

Settings - URL normalization: https://developers.cloudflare.com/rules/normalization/how-it-works/

https://developers.cloudflare.com/rules/ - order: Origin -> Cache -> Conf -> Single -> Page

Name Free Desc
Transform Rules free 10 no Regex support
Origin Rules 10 Override destination port
Cache Rules 10 cache properties of your HTTP requests
Configuration Rules 10 expressions / no Regex support
Single Redirects 5~20
Page Rules 3 require a “proxied” DNS record, highest priority rule at the top

SSL/TLS

SSL Modes

https://developers.cloudflare.com/ssl/origin-configuration/ssl-modes/

Flexible: visitor - Edge cert - cf
Full: cf - self signed certificate - server
Full (strict): cf - trusted CA  - server

Edge Certificates

Automatic HTTPS Rewrites safely eliminates mixed content issues by rewriting insecure URLs dynamically from known secure hosts to their secure counterpart.

Page Rules - Always Use HTTPS

Page Rules - Forwarding URL

Origin CA

15-years wildcard | visitor - Edge cert - cf - Origin CA - server: https://blog.cloudflare.com/cloudflare-ca-encryption-origin/

PEM: Apache httpd and NGINX
PKCS#7: Microsoft’s IIS or Apache Tomcat

CNAME Flattening

  • CNAME records normally can not be on the zone apex. We use CNAME flattening to make it possible.
  • DNS/Settings

https://developers.cloudflare.com/dns/additional-options/cname-flattening/ - speeds up CNAME resolution - CNAME flattening occurs by default

Workers

TypeScript

https://github.com/cloudflare/workers-sdk/tree/main/templates/worker-typescript

npm init cloudflare my-project worker-typescript

Wrangler (Workers CLI)

https://developers.cloudflare.com/workers/get-started/guide/

npm install -g wrangler # nodejs v16.13.0+
wrangler login  # install volta/nvm if error
wrangler whoami # view permissions
wrangler init <YOUR_WORKER> && cd <YOUR_WORKER>

wrangler generate [name] [template]: https://github.com/cloudflare/templates

npm start # [l] turn on/off local mode
npm test
npm run deploy || wrangler publish # 1st time: wait 1min

Workers > Overview # re-login web if no menu - Online dev: worker page > click Quick edit

wrangler dev: https://developers.cloudflare.com/workers/learning/debugging-workers/

wrangler tail --format=pretty: https://developers.cloudflare.com/workers/learning/logging-workers/

Workers as Reverse Proxy

Bulk origin override

https://developers.cloudflare.com/workers/examples/bulk-origin-proxy

Reflare

https://github.com/xiaoyang-sde/reflare

npm init cloudflare reflare-app https://github.com/xiaoyang-sde/reflare-template

Storage

https://developers.cloudflare.com/workers/platform/storage-objects/

R2 - S3 object

https://developers.cloudflare.com/r2/platform/pricing/

Product Free Paid - Rates
Storage 10 GB / month $0.015 / GB-month
Class A Operations 1 million requests / month $4.50 / million requests
Class B Operations 10 million requests / month $0.36 / million requests

KV - key-value

https://developers.cloudflare.com/workers/reference/storage/namespaces/

1 GB free: https://developers.cloudflare.com/workers/platform/pricing/#workers-kv

Value size 25MB / 100,000 reads per day: https://developers.cloudflare.com/workers/platform/limits#kv-limits

D1 - RDB

https://developers.cloudflare.com/d1/platform/pricing/ - only be charged for base storage plus any database operations performed

Durable Objects - Workers Paid plan

https://developers.cloudflare.com/workers/learning/using-durable-objects/

Queues - Workers Paid plan

job queueing, batching and inter-Service (Worker to Worker) communication.

Paid

Product Fee Desc
Workers Paid plan $5 / month separate from any other Cloudflare plan (Free, Professional, Business)
Images $5 / month Store, resize, optimize and serve images at scale
Stream $5 / month Live and on-demand video streaming in minutes

Community

domain: https://community.cloudflare.com/c/website-application-performance/88