Skip to main content

Token V2 — signed URLs

Token V2 signs URLs with HMAC (signed URLs): you (or your backend) create a link that includes a signature, and the edge checks the signature before serving the content. URLs without a valid signature are blocked.

Use it to deliver time-limited HLS/video, time-limited file download links, and to block direct access to the original paths. Example: you sell video courses — your backend generates a signed .m3u8 link that expires after 2 hours for each viewing session.

Good to know: the signature is not tied to an IP, and the link can be reused until it expires. Anyone with a valid link can open it, even from another device. To limit link sharing, set a short expiry and choose a Path Segments value deep enough that each link opens only the directory of a single video. If you need stricter sharing protection (single-use tokens, tied to an IP), use X-Vtoken.

Unlike X-Vtoken (which signs each request through the X-Vtoken header and suits app SDKs — see its own article), Token V2 signs the URL itself, which suits cases where you can only distribute links and cannot control the client's headers (for example HLS players).

Token V2 is in the Access Control tab (the Token V2 section), not in a tab of its own — but it is independent of the Access Control Enabled switch: once turned on, Token V2 is enforced by the edge even when IP/Geo/ASN rules are off.

Before you start​

  • The domain has been added and points to VNIS.
  • Your backend/application can sign URLs with the same algorithm and secret that you set in the rule.
  • Understand that the secret must be kept private — put it only on the server that generates links, and do not embed it in public clients.

How to configure​

  1. Go to Domains → select a domain → Access Control tab → Token V2 section.
  2. Turn on the Enabled switch of the Token V2 section (you do not need to turn on Access Control's Enabled).
  3. Click Add rule. Set the Rule Name, Secret Key (≥8 characters, with a button to generate a random one), choose an Algorithm, and set Match Conditions (for example URL Path · Starts With · /vod/), Path Segments and Priority.
  4. (Optional) Add Whitelisted IPs for ranges that are exempt from the check.
  5. Click the tab's Save button (Create the first time) and wait a few seconds for it to sync.

Configuration fields​

FieldMeaningValuesDefaultNotes
EnabledTurns Token V2 on for the domainOn/offOff—
Whitelisted IPsIPs/CIDRs that skip the signature checkList of CIDRs—CIDRs broader than v4 /8 or v6 /16 are rejected (same limit as Access Control)
(Rule) secretSecret key for signing URLs≥8 characters, required—GET returns it masked as ********; if a PUT keeps ********, the old value is kept based on the rule name (not overwritten with an empty value)
(Rule) nameRule nameRequired, unique within the domain—Duplicate name → 400 (the secret is kept based on the name)
(Rule) algorithmSigning algorithmhmac_sha256, md5hmac_sha256Omitting this field in an API call = hmac_sha256; sending an empty string "" → 400. Use hmac_sha256; md5 is only for compatibility with older systems
(Rule) match conditionsScope the rule applies toFor example URL Path · Starts With · /vod/—Set in the console under Match Conditions (API: conditions). Starts With is case-sensitive: a /vod/ rule does not match /VOD/. If the origin returns the same file for both, use Starts With (ignore case)
(Rule) conditionsAdditional conditions for the rule to match≤20 conditions—AND between conditions, OR between values within a condition.
(Rule) path segmentsNumber of leading path segments included in the signature1–202The signature covers the whole directory formed by the first N segments: every file and subdirectory below it can be opened with the same signature. See How to sign a URL
(Rule) priorityRule priorityInteger—Lower numbers run first; evaluation stops at the first matching rule

Limit: up to 50 rules (rules ≤50) for Token V2 per domain.

How to sign a URL​

The format below is for rules with Algorithm = md5:

URL = https://<domain>/<signature>:<n>/<expiry>/<path>/<file>
expiry = expiry time, Unix time (seconds)
path = the directory part, without a leading "/", with exactly N segments (N = the rule's Path Segments)
signature = base64url( md5("<expiry> <path> <secret>") ), with trailing "=" characters removed

PHP example that signs the directory vod/course-1 (2 segments, matching Path Segments = 2) for the file index.m3u8, expiring after 2 hours:

$secret = getenv('TOKENV2_SECRET'); // keep on the backend, never send to the browser
$path = 'vod/course-1';
$e = time() + 7200;
$sig = rtrim(strtr(base64_encode(md5("$e $path $secret", true)), '+/', '-_'), '=');
$url = "https://example.com/$sig:" . (substr_count($path, '/') + 1) . "/$e/$path/index.m3u8";

When it receives a request, the edge checks the signature and the expiry, then removes the /<signature>:<n>/<expiry> part before sending /<path>/<file> to the origin. No changes are needed on the origin.

  • The signed path must have exactly N segments, equal to the rule's Path Segments; a different number of segments → 403. Set :<n> to the same number.
  • The signature covers the directory, not the file name. For HLS, if you sign the directory containing the manifest, the segments in the same directory share the signature; the manifest must use relative paths.
  • Changing the signature, changing the expiry in the URL, signing with the wrong secret, or using an expired link all result in 403.
  • For hmac_sha256 rules (the default), contact VNETWORK for the corresponding signing format.

Configuration examples​

Example 1 — Protect VOD video with time-limited links.

  • Enabled: on · Rule: secret s3cr3t-hls-... (≥8), algorithm md5, Match Conditions: URL Path · Starts With · /vod/, Path Segments 2.
  • The backend generates a signed .m3u8 link (following How to sign a URL) for each viewing session.
  • Result: unsigned or incorrectly signed /vod/... links are blocked; correctly signed links play.
  • How to check: open the signed link → plays normally; change 1 character in the signature and open it again → blocked.

Example 2 — Several rules for several areas, with priorities.

  • Rule A: Starts With /premium/, its own secret, priority 10.
  • Rule B: Starts With /, a different secret, priority 100 (the "catch-all" rule runs later).
  • Result: /premium/* requests match Rule A first (lower priority); everything else falls through to Rule B.
  • How to check: a link signed with A's secret for /premium/... → OK; using B's secret by mistake for /premium/... → blocked.

Example 3 — Exempt an internal IP range.

  • Whitelisted IPs: 198.51.100.0/24 (no broader than /8 for v4 or /16 for v6).
  • Result: requests from this range do not need a signed URL; other IPs still need a valid link.
  • How to check: open an unsigned link from an IP in the range → OK; from an IP outside → blocked.

Order of evaluation​

  • Within a domain with several Token V2 rules: lower priority numbers run first, first-match.
  • Token V2 runs after X-Vtoken, and before Redirects / Bot-mgmt / Rate Limit / WAF.
  • Access Control allow also bypasses Token V2 (a matching allow lets the request straight through — only when Access Control is Enabled). Do not allow broad ranges if you still want to require signed links.
  • Token V2 does not depend on the Access Control Enabled switch; however, clicking Remove in the Access Control tab also deletes the Token V2 configuration.
  • Firewall Rules allow/bypass do not bypass Token V2 — requests let through by the firewall still need a valid signed URL.

Troubleshooting​

SymptomCauseFix
Saving returns a secret errorSecret < 8 charactersUse a secret of ≥8 characters
The secret is "lost" after editing a ruleThe ******** field was cleared or overwrittenLeave ******** unchanged if you want to keep the old secret (the system keeps it based on the rule name)
Saving returns 400 when adding to the whitelistCIDR broader than /8 (v4) / /16 (v6)Narrow the range
A signed link is still blockedWrong algorithm/secret, or the number of signed path segments differs from the rule's Path SegmentsAlign the algorithm, secret and number of path segments between the backend and the rule
An unsigned link still opensAn Access Control allow rule matches the request, the IP is in Whitelisted IPs, or the URL's letter case differs from the Starts With conditionNarrow the allow/whitelist; use Starts With (ignore case)
A signed link is blocked with 403Wrong signature, missing token, or expired tokenCheck the secret and the expiry used when signing the URL; see the block reason in Request Logs (token_invalid / token_missing / token_expired)

FAQ​

  • Token V2 or X-Vtoken? If you can sign URLs (distributing links, HLS) → Token V2. If you have a client SDK that signs a header for each request → X-Vtoken (stronger replay protection). You can use each one for a different scope.
  • Is a signed link locked to an IP or single-use? No. The link can be reused, from any IP, until it expires. Control it with a short expiry and narrow Path Segments.
  • Can I use md5? Yes. The signing format above is for md5; for hmac_sha256, contact VNETWORK for the signing format.
  • Can I see the secret when I GET the configuration again? No. The secret is masked as ********. Leave this field unchanged when saving so it is not overwritten.
  • What status code does the edge return for an invalid signature? It returns 403 (Forbidden) and blocks access. The reason recorded in Request Logs is token_invalid (wrong signature/format), token_missing (missing token) or token_expired (expired).