Serve one custom domain from more than one datacenter

Use one public entry point: it looks up which datacenter holds each name and forwards every request it does not hold itself, keeping the original Host header.

An app can run in several datacenters and still be reached at one name, app.example.com. DNS sends a connection to one address, so give that address to a single entry point and let it decide where each request goes. Pointing a hostname at several datacenters with DNS round-robin does not work on its own: a request can land on a datacenter that does not hold that app. HTTP keeps the name in a header instead, so a router can use it.

Why the Host header is the key

An HTTP request carries the hostname the client asked for in the Host header (in HTTP/2 and HTTP/3, sometimes the :authority pseudo-header). RFC 9110 describes it as the way a server tells requests for different names apart:

"The "Host" header field in a request provides the host and port information from the target URI, enabling the origin server to distinguish among resources while servicing requests for multiple host names."

That is why an entry point can receive a request for app.example.com, notice that this datacenter does not hold that name, open a connection to the datacenter that does, and repeat the request with the same Host header. To the app, the request still arrived at app.example.com. Cookies, sign-in callbacks and absolute redirects keep working because the app only ever sees one origin.

What the entry point does

  1. Read the hostname from the request.
  2. Look it up in a small name service that records which datacenter holds it.
  3. If this datacenter holds it, serve it locally.
  4. Otherwise, forward the request to the datacenter that does, keeping Host.
  5. If the lookup finds nothing, answer 404 rather than guessing.

The name service can be tiny: a table of name to datacenter, written when an app is created and read on each request (cached briefly). It does not need to be in the request path for the app itself, only for picking the datacenter.

One wildcard per ingress controller

Routers choose a backend by matching the request's host. In Kubernetes, an Ingress rule can name a precise host or a wildcard, and a wildcard covers exactly one DNS label:

"Hosts can be precise matches (for example "foo.bar.com") or a wildcard (for example "*.foo.com"). Precise matches require that the HTTP host header matches the host field. Wildcard matches require the HTTP host header is equal to the suffix of the wildcard rule."

"*.foo.com ... baz.bar.foo.com ... No match, wildcard only covers a single DNS label"

Traefik's Host matcher follows the same idea, and its default priority is the length of the rule:

"The Host and HostRegexp matchers allow matching requests that are targeted to a given host."

"To avoid path overlap, routes are sorted, by default, in descending order using rules length."

Two datacenters in separate clusters can each run their own ingress controller and each own a *.example.com rule. Two datacenters in the same cluster share one ingress controller: two identical wildcard rules match the same requests, and Traefik says to set a priority when overlapping routes need a fixed winner. The simpler rule is to let one datacenter own the wildcard and reach the other over the cluster's private network, using its internal service address instead of a public hostname.

Where a forwarded request connects

Tell the app the original scheme

Forwarding over a private network is often plain HTTP even though the visitor used HTTPS. Proxies report the original protocol in X-Forwarded-Proto, which is a de facto header rather than a standard one:

"The HTTP X-Forwarded-Proto (XFP) request header is a de-facto standard header for identifying the protocol (HTTP or HTTPS) that a client used to connect to a proxy or load balancer."

"Not part of any current specification. The standardized version of this header is Forwarded."

The app has to trust that header (usually a "trust proxy" setting in the web framework), or it will build http:// redirects and think secure cookies are not secure. The standardized Forwarded header carries the same information: "The "Forwarded" HTTP header field is an OPTIONAL header field that, when used, contains a list of parameter-identifier pairs that disclose information that is altered or lost when a proxy is involved in the path of the request."

Stop forwarding loops

Mark each forwarded request with a value only your datacenters know, and count the hops. Allow the small number of hops your topology needs (for example, a chain of two datacenters) and refuse anything beyond it. Without the count, two datacenters whose name tables briefly disagree can send the same request back and forth until it times out. Strip the marker and the count before the request reaches the app, so an app cannot set them.

Checklist

Sources

All checked on 2026-11-10.


First version written with AI assistance and checked against the sources on 2026-11-10. Found a mistake? Fix it or open an issue. Text licensed under CC BY 4.0.