Skip to content

Server Loopback & DoH Routing

How WP Zbridge uses DNS over HTTPS (DoH) and CURLOPT_RESOLVE to bypass webhost localhost loopbacks.

Server Loopback & DoH Routing Deep Dive

Section titled “Server Loopback & DoH Routing ”

When a WordPress PHP server sends an HTTP request to its own public domain (e.g. https://yourstore.com/zaraz/1f3a9c0b7d2e4a6c, its Zaraz HTTP Events API path), hosting environments frequently misroute the traffic.


Many managed WordPress hosts (such as WP Engine, Kinsta, Cloudways, SiteGround) map your domain to 127.0.0.1 or internal private IPs inside /etc/hosts.

When PHP makes a cURL request to its own Zaraz HTTP Events API path, the server connects to itself rather than routing out to Cloudflare’s Anycast edge network. Because the local web server doesn’t execute Cloudflare Zaraz, the request fails with a 404 or connection timeout.


The WP Zbridge Solution: DNS over HTTPS (DoH)

Section titled “The WP Zbridge Solution: DNS over HTTPS (DoH)”

So that server-to-server events reach Cloudflare instead of your own server, WP Zbridge resolves your domain to Cloudflare’s addresses:

  1. DNS over HTTPS Query: WP Zbridge queries https://cloudflare-dns.com/dns-query via HTTPS to discover real public Cloudflare Anycast edge IP addresses for your domain.
  2. Direct Anycast Pinning (CURLOPT_RESOLVE): Pin the cURL socket to the discovered Anycast IP:
    curl_setopt($ch, CURLOPT_RESOLVE, ["{$host}:443:{$anycastIp}"]);
  3. Outcome: The request skips the local hosting server’s /etc/hosts entry and goes to Cloudflare.