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
- Go to Domains → select a domain → Access Control tab → Token V2 section.
- Turn on the Enabled switch of the Token V2 section (you do not need to turn on Access Control's Enabled).
- 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. - (Optional) Add Whitelisted IPs for ranges that are exempt from the check.
- Click the tab's Save button (Create the first time) and wait a few seconds for it to sync.
Configuration fields
| Field | Meaning | Values | Default | Notes |
|---|---|---|---|---|
| Enabled | Turns Token V2 on for the domain | On/off | Off | — |
| Whitelisted IPs | IPs/CIDRs that skip the signature check | List of CIDRs | — | CIDRs broader than v4 /8 or v6 /16 are rejected (same limit as Access Control) |
| (Rule) secret | Secret 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) name | Rule name | Required, unique within the domain | — | Duplicate name → 400 (the secret is kept based on the name) |
| (Rule) algorithm | Signing algorithm | hmac_sha256, md5 | hmac_sha256 | Omitting 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 conditions | Scope the rule applies to | For 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) conditions | Additional conditions for the rule to match | ≤20 conditions | — | AND between conditions, OR between values within a condition. |
| (Rule) path segments | Number of leading path segments included in the signature | 1–20 | 2 | The 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) priority | Rule priority | Integer | — | 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), algorithmmd5, Match Conditions: URL Path · Starts With ·/vod/, Path Segments2. - The backend generates a signed
.m3u8link (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, priority10. - Rule B: Starts With
/, a different secret, priority100(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
allowalso bypasses Token V2 (a matchingallowlets the request straight through — only when Access Control is Enabled). Do notallowbroad 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/bypassdo not bypass Token V2 — requests let through by the firewall still need a valid signed URL.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| Saving returns a secret error | Secret < 8 characters | Use a secret of ≥8 characters |
| The secret is "lost" after editing a rule | The ******** field was cleared or overwritten | Leave ******** 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 whitelist | CIDR broader than /8 (v4) / /16 (v6) | Narrow the range |
| A signed link is still blocked | Wrong algorithm/secret, or the number of signed path segments differs from the rule's Path Segments | Align the algorithm, secret and number of path segments between the backend and the rule |
| An unsigned link still opens | An Access Control allow rule matches the request, the IP is in Whitelisted IPs, or the URL's letter case differs from the Starts With condition | Narrow the allow/whitelist; use Starts With (ignore case) |
| A signed link is blocked with 403 | Wrong signature, missing token, or expired token | Check 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 formd5; forhmac_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) ortoken_expired(expired).