Secure your origin
Your origin server ↗ is a physical or virtual machine that is not owned by Cloudflare and hosts your application content (data, webpages, etc.).
Receiving too many requests can be bad for your origin. These requests might increase latency for visitors, incur higher costs — particularly for cloud-based machines — and could knock your application offline.
When you secure origin connections, it prevents attackers from discovering and overloading your origin server with requests.
-
DNS:
- Proxy records (when possible): Set up proxied (orange-clouded) DNS records to hide your origin IP addresses and provide DDoS protection. As part of this, you should allow Cloudflare IP addresses at your origin to prevent requests from being blocked.
- Review DNS-only records: Audit existing DNS-only records (
SPF
,TXT
, and more) to make sure they do not contain origin IP information. - Evaluate mail infrastructure: If possible, do not host a mail service on the same server as the web resource you want to protect, since emails sent to non-existent addresses get bounced back to the attacker and reveal the mail server IP.
- Rotate origin IPs: Once onboarded, rotate your origin IPs, as DNS records are in the public domain. Historical records are kept and would contain IP addresses prior to joining Cloudflare.
Cloudflare Tunnel (HTTP / WebSockets)
Cloudflare Tunnel connects your resources to Cloudflare without a publicly routable IP address, by creating an outbound-only connections to Cloudflare’s global network.
- Security: Very secure.
- Availability: All customers.
- Challenges: Requires installing the
cloudflared
daemon on origin server or virtual machine.
HTTP Header Validation
Only allow traffic with specific (and secret) HTTP headers.
- Security: Moderately secure.
- Availability: All customers.
- Challenges:
- Requires more configuration efforts on application- and server-side to accept those headers.
- Basic authentication is vulnerable to replay attacks. Because basic authentication does not encrypt user credentials, it is important that traffic always be sent over an encrypted SSL session.
- There might be valid use cases for a mismatch in SNI / Host headers such as through Page Rules, Load Balancing, or Workers, which all offer HTTP Host Header overrides.
- Process:
- Use Transform rules or Workers to add an HTTP Auth Header.
- Configure your origin server to restrict access based on the HTTP Auth Header (or perform HTTP Basic Authentication).
- Configure your origin server to restrict access based on the HTTP Host Header ↗. Specifically, only allow requests which contain expected HTTP Host Header values, and reject all other requests.
JSON Web Tokens (JWT) Validation
Only allow traffic with the appropriate JWT.
- Security: Very secure.
- Availability: Some customers.
- Challenges:
- Requires either installing incremental software or modifying application code.
- Lots of manual work.
- Resources:
Authenticated Origin Pulls
Authenticated Origin Pulls helps ensure requests to your origin server come from the Cloudflare network.
- Security: Very secure.
- Availability: All customers.
- Challenges:
- Requires Full or Full (strict) encryption modes.
- Requires more configuration efforts for application and server, such as uploading a certificate and configuring the server to use it.
- For more strict security, you should upload your own certificate. Although Cloudflare provides you a certificate for easy configuration, this certificate only guarantees that a request is coming from the Cloudflare network.
- Not scalable for large numbers of origin servers.
Cloudflare Tunnel (SSH / RDP)
Cloudflare Tunnel connects your resources to Cloudflare without a publicly routable IP address, by creating an outbound-only connections to Cloudflare’s global network.
- Security: Very secure.
- Availability: All customers.
- Challenges: Requires installing the
cloudflared
daemon on origin server or virtual machine.
Allowlist Cloudflare IP addresses
Explicitly block all traffic that does not come from Cloudflare IP addresses (or the IP addresses of your trusted partners, vendors, or applications).
- Security: Moderately secure.
- Availability: All customers.
- Challenges:
- Requires allowlisting Cloudflare IP ranges at your origin server.
- Vulnerable to IP spoofing.
Cloudflare Magic Transit
Cloudflare Magic Transit is a network security and performance solution that offers DDoS protection, traffic acceleration, and more for on-premise, cloud-hosted, and hybrid networks.
- Security: Very secure.
- Availability: Enterprise-only.
- Challenges
- Client’s routers must:
- Support anycast tunneling.
- Allow configuration of at least one tunnel per Internet service provider (ISP).
- Support maximum segment size (MSS) clamping.
- Client’s routers must:
Cloudflare Network Interconnect
Cloudflare Network Interconnect allows you to connect your network infrastructure directly with Cloudflare – rather than using the public Internet – for a more reliable and secure experience.
- Security: Very secure.
- Availability: Enterprise-only.
- Challenges
- Requires some networking knowledge.
- Only applies to some customer use cases.
Cloudflare Aegis
Cloudflare Aegis provides dedicated egress IPs (from Cloudflare to your origin) for your layer 7 WAF, CDN, and Spectrum services. The egress IPs are reserved exclusively for your account so that you can increase your origin security by only allowing a small list of IP addresses through your layer 3 firewall.
Refer to the introductory blog post ↗ for details, or to the Multi-vendor reference architecture for an example use case.
- Security: Very secure.
- Availability: Enterprise-only.
- Challenges: Requires network-level firewall policies.