Loading...

CDN.com.tr Help

Origin connection: the real visitor IP, locking down your origin, WebSocket and timeouts

Edge servers pass the visitor's IP address in the X-CDN-Client-IP header. Open your origin to the CDN only with a secret header you add to every rule. Configure WebSocket and long-running requests per rule.

Origin connection: the real visitor IP, locking down your origin, WebSocket and timeouts

Edge servers pass the visitor's IP address in the X-CDN-Client-IP header. Open your origin to the CDN only with a secret header you add to every rule. Configure WebSocket and long-running requests per rule.

Use cases

A team runs a web application with logins on its own server and puts CDN and WAF in front of it. They want the real visitor IP in their logs, to reject requests that do not come through the CDN and to keep WebSocket connections working.

Workflow

  1. Make your application read the real visitor IP from the X-CDN-Client-IP header.
  2. Generate a long random value. Write the same line in the Headers sent to your origin field of every delivery rule in your account, for example X-CDN-Auth <value>.
  3. Once the header is live in all rules and your domain points to the CDN, reject requests without this header on your origin.
  4. For paths that use WebSocket, create a separate rule and switch on Allow WebSocket connections. For long-running requests, raise the Origin response timeout (seconds) value.
  5. If your API uses PUT, PATCH or DELETE, add these methods to the WAF: Allowed HTTP methods list.

Checks

  • The real visitor IP arrives in the X-CDN-Client-IP header. It holds a single value and the edge server rewrites it on every request; a header of the same name sent by the visitor is not used. The value can also be an IPv6 address.
  • Edge servers also send X-Real-IP and X-Forwarded-For. If you use X-Forwarded-For, take the rightmost value, not the first; the visitor can write the values on the left.
  • Headers sent to your origin are set per rule: one header per line, in the form Header-Name value. When you add a new rule, add the secret header to it too; otherwise your origin rejects that rule's requests.
  • Make the secret header's value a random value of at least 32 characters, letters and digits only. On rules that connect to your origin over HTTPS, the header travels encrypted.
  • Rely on the secret header rather than locking your origin with an IP list alone. We tell you the current addresses of the edge servers linked to your account on request.
  • On a rule with Allow WebSocket connections on, connections reach your origin and stay open while data flows; responses on that path are not cached. WebSocket cannot be switched on in a rule that optimizes images, so create a separate rule for the WebSocket path.
  • The origin response timeout is 60 seconds by default: if your origin sends no data for 60 seconds, the request ends with a 504 error and an idle WebSocket connection closes. You can set it per rule between 1 and 3,600 seconds. As long as data flows, there is no limit on the total length of a connection.
  • On the domain of your Managed Container apps, WebSocket is on by default and the timeout is 300 seconds unless the rule sets another value.
  • With WAF on, GET, HEAD, POST and OPTIONS are allowed by default. The JavaScript challenge applies only to page requests from browsers and does not affect API requests.

Frequently asked questions

How do I check the secret header in Apache or nginx?

In Apache, add the lines RewriteEngine On, RewriteCond %{HTTP:X-CDN-Auth} !=<value> and RewriteRule ^ - [F] at the very top of .htaccess. In nginx, add if ($http_x_cdn_auth != "<value>") { return 403; } to the server block. Switch the check on last: first the header must be live in all rules and your domain must point to the CDN.

Is WebSocket supported?

Yes. Create a rule for the path that uses WebSocket and switch on Allow WebSocket connections. The connection reaches your origin and stays open while data flows; no caching is used on that path.

How long can a request stay open?

As long as data flows, there is no limit on the total time. The limit is how long the edge waits with no data flowing: 60 seconds by default. You can raise it up to 3,600 seconds in the rule's Origin response timeout (seconds) field.

Where do I read the visitor's real IP?

From the X-CDN-Client-IP header. The edge server writes this header itself on every request and does not use a header of the same name sent by the visitor. If you use X-Forwarded-For, take the rightmost value.

Related pages

Manage DNS records

Add, update, delete, import, export, and move eligible records to cloud DNS.

HTTP/3 and IPv6 at the edge

Since September 2026 the CDN.com.tr edge serves every hostname over HTTP/3 (QUIC) and IPv6 in addition to HTTP/2 and IPv4. Browsers switch on their own; there is no per-account setting, and your origin can stay IPv4-only.