☰
WEB SECURITY / PRACTICE

WordPress DDoS Protection with a CDN and Origin Server Access Restrictions

WordPress DDoS Protection with a CDN and Origin Server Access Restrictions

Even an updated WordPress installation with strong passwords can become unavailable during a DDoS attack. In such cases, attackers are not necessarily trying to compromise the admin panel: they send a large number of requests to exhaust CPU, memory, bandwidth, or PHP limits on the web server.

You need to protect not only the domain and the website itself, but also the origin server—the actual server running WordPress. If its IP address is directly accessible, an attacker can bypass the CDN and send traffic straight to the hosting environment. Below is a practical approach that helps reduce this risk and properly verify the result.

How WordPress Protection Through a CDN Works

A CDN or reverse proxy is placed between visitors and the origin server. The user requests the domain, the request reaches the CDN network, and only then is it forwarded to the WordPress server if the response was not served from cache.

This provides several advantages: part of the traffic is processed on the CDN infrastructure, static files can be delivered without invoking PHP, and filtering and rate-limiting rules are applied before the load reaches the hosting environment.

It is important that the CDN operates as a proxy. A simple DNS record that only points to the server IP does not hide the origin or filter traffic.

  • Connect the domain to a CDN or reverse proxy and make sure proxying is enabled for web traffic.
  • Check that A and AAAA records do not unnecessarily expose the real server address.
  • Keep a separate secure channel for administrative server access, such as SSH through a VPN or from allowlisted IP addresses.
  • Do not treat a CDN as a complete replacement for a firewall: access to the origin must be restricted at the network level.

How to Hide and Protect the Origin Server

After connecting the CDN, configure the firewall so that HTTP and HTTPS ports accept connections only from the CDN provider’s official IP ranges. Obtain the list of ranges from your provider’s documentation and update it regularly.

The rule should apply to inbound web traffic. SSH, the server control panel, the database, and service ports should not be exposed to the entire internet. Allow access only from administrative IP addresses, a VPN, or another controlled source.

If the server supports IPv6, check it separately. A common mistake is to restrict IPv4 while leaving the IPv6 address space open. In that case, the origin can still be attacked directly.

  • Allow TCP ports 80 and 443 only from current CDN networks.
  • Block direct access to web ports from all other addresses.
  • Close unused ports and check the rules for both IPv4 and IPv6.
  • Do not publish the origin IP in DNS records, test subdomains, old configurations, or service panels.
  • After changing the IP, check DNS, the firewall, access logs, and external integration settings.

What to Do If the Origin IP Has Already Been Exposed

If the real server address is already known, simply enabling a CDN is not enough. Assess whether the IP can be changed, then update DNS, firewall rules, TLS configuration, allowlists for external services, and monitoring rules.

After migration, do not disable the old address immediately if it is used by email, APIs, or other services. First create a list of dependencies and verify them so that legitimate users are not made unable to access those services.

  • Find old DNS records, subdomains, and test environments.
  • Check whether the server returns identical headers or service responses that could reveal the origin.
  • Check mail records separately: MX records should not accidentally point to the web server unless this is required.
  • After changing the address, monitor logs and network connections throughout the transition period.

Rate Limiting for Resource-Intensive WordPress URLs and Functions

Even behind a CDN, an attacker can create load on the origin if every request forces WordPress to execute PHP code or access the database. Rate limiting should therefore be applied to resource-intensive routes, rather than using the same rule for the entire site.

Pay particular attention to search, forms, login, password recovery, XML-RPC, API endpoints, and pages with filters or complex database queries. Rules must account for normal user behavior; otherwise, real customers or editors may be blocked.

It is generally more convenient to implement rate limiting on the CDN or reverse proxy, where a request can be rejected before it reaches WordPress. Additional restrictions can be configured on the web server and in the application itself.

  • Apply stricter limits to admin login, search, forms, and password recovery.
  • Do not set the same limit for static files and PHP requests.
  • Use a challenge or temporary blocking for suspicious spikes if the CDN supports it.
  • Account for proxy headers so that the server correctly identifies the client’s real IP address.
  • Make sure CDN internal IPs are not recorded in logs as the addresses of all visitors.

Caching WordPress and Elementor Without Breaking the Site

Caching reduces the number of requests to PHP and the database. For most sites, it is safe to start with static resources: CSS, JavaScript, images, web fonts, icons, and other files that change infrequently.

This is especially important for Elementor sites, whose pages may load a large number of CSS files, JavaScript resources, images, and fonts. If these resources are delivered from the CDN, the origin receives fewer repeat requests and pages load faster during traffic peaks.

HTML page caching should be enabled more carefully. Do not cache personalized content, carts, checkout, user pages, or responses that depend on cookies or sessions. After changing CSS or templates, clear the relevant cache and check the pages in a private browsing window.

  • Start with static CSS, JavaScript, images, and fonts.
  • Use a longer cache lifetime for versioned files whose URLs change after updates.
  • Exclude the admin area and dynamic functions from caching.
  • Check Elementor forms, the mobile version, font loading, and page rendering after clearing the cache.
  • Do not cache server errors or pages containing private data.

Monitoring Traffic Spikes and Analyzing Logs

Protection cannot be assessed solely by whether the site remains available. You need to understand which URLs generate the most load, how many requests reach the origin, which responses the server returns, and whether the number of 5xx errors is increasing.

Monitoring should cover the CDN, reverse proxy, web server, PHP, and database. A sharp increase in requests to one URL, a large number of POST requests, repeated user agents, or a surge of requests from different addresses may indicate an automated attack. However, unusual traffic alone does not prove a DDoS attack: it may be caused by an advertising campaign, indexing, or viral content.

  • Compare total CDN traffic with the number of requests that reach the origin.
  • Monitor CPU, RAM, disk operations, PHP workers, and database connections.
  • Configure alerts for increases in 5xx errors, response times, and firewall denials.
  • Retain logs long enough for analysis, while controlling their size and access to them.
  • Check whether WordPress sees the visitor’s real address rather than only the CDN address.

Verifying the Configuration After Setup

After connecting the CDN, do not limit testing to the home page. Check DNS, HTTPS, redirects, static files, forms, authentication, and administrative access. An error in the allowlist can make the site unavailable to everyone or, conversely, leave the origin exposed.

Testing should be performed from different networks: home, mobile, and, where possible, a separate monitoring server. Do not perform aggressive load tests on a production site without coordinating with the hosting provider and having a clear recovery plan.

  • Make sure DNS points to the CDN rather than directly to the origin.
  • Check that direct requests to the origin are rejected by the web server from unauthorized addresses.
  • Verify the certificate, HTTPS chain, and encryption mode between the CDN and the origin.
  • Open Elementor pages and check CSS, JavaScript, images, fonts, and forms.
  • Review the logs after a test request: they should contain correct client addresses and a clear traffic source.
  • Save backups of the firewall, DNS, and reverse proxy configurations before making further changes.

Frequently asked questions

Is connecting a CDN enough to protect WordPress from DDoS attacks?

No. A CDN helps filter and distribute traffic, but the origin server must also be protected with a firewall. If it can be accessed directly, the CDN can easily be bypassed.

Should access to the origin server be blocked completely?

For HTTP and HTTPS, it is generally advisable to allow only the CDN’s IP ranges. Administrative services should remain accessible only from controlled addresses, through a VPN, or via another secure channel.

Which Elementor files are safe to cache?

These are generally static CSS, JavaScript, images, icons, and fonts. Dynamic pages, forms, personal data, and session-dependent functions should be excluded from the cache.

What should I do if the site becomes unavailable after enabling the CDN?

Check DNS, certificates, firewall rules, the CDN IP allowlist, IPv4 and IPv6, as well as reverse proxy and web server logs. The most common causes are an incomplete list of allowed networks or an HTTPS configuration error between the CDN and the origin.

Conclusion

A reliable WordPress DDoS protection architecture consists of several layers: a CDN in front of the site, a hidden origin, firewall access restrictions, rate limiting for resource-intensive routes, static resource caching, and continuous monitoring.

Start by checking whether the server is directly accessible, then configure the CDN allowlist, and only after that optimize caching and request rules. For Elementor, the greatest practical benefit usually comes from delivering CSS, JavaScript, images, and fonts through the CDN without invoking PHP for every request.

← All web security materials