How to stop people re-streaming or hotlinking your live stream
Once a live stream's URL is public, anyone can embed it on their own site, or run a scraper in a data center that re-streams it, and you pay for the traffic. No single setting stops every case; the answer is layers, each cheap to apply and each closing a different gap.
| Who is taking the stream | Layer that stops it |
|---|---|
| Another site embeds your player or stream | Referer/Origin allowlist |
| A playback link is copied to a forum, chat or app | Signed URL with a short expiry |
| A token is lifted out of your player and replayed | Per-viewer session token, plus your authorization callback |
| A scraper in a data center pulls and re-streams | Request-source policy, then address blocking |
| Someone publishes into your channel | Stream Key per ingest domain, rotated; publisher IP allowlist |
1. Signed playback URLs
Your backend signs the playback URL with an expiry and returns the complete URL to the page. A copied link stops working once it expires, so a URL pasted into a forum or another site is only good for a short time. The signing key never reaches the browser.
GET /live/camera-01?wsTime=1780000000&wsSecret=<32 hex> HTTP/1.1
Host: play.example.com
wsTime = decimal Unix expiry, in seconds
wsSecret = lowercase_hex(MD5(Key + StreamName + wsTime))
import { createHash } from "node:crypto";
// Server only: PLAYBACK_SIGNING_KEY is the key set on the playback domain.
export function signedPlaybackUrl(streamName: string, ttlSeconds = 120) {
const wsTime = Math.floor(Date.now() / 1000) + ttlSeconds;
const wsSecret = createHash("md5")
.update(process.env.PLAYBACK_SIGNING_KEY + streamName + wsTime)
.digest("hex");
return `https://play.example.com/live/${encodeURIComponent(streamName)}?wsTime=${wsTime}&wsSecret=${wsSecret}`;
}
- The expiry may not exceed the maximum validity the playback domain allows.
- MD5 here is a compatibility token calculation, not content encryption; the key stays on your server.
- Keep the expiry short: the link only has to survive from your page load to the start of playback.
2. Session tokens: a copied link cannot keep playing
Signed URLs gate the requests that start playback. When playback starts, the player gets its own session id and session token, and every later request (heartbeats, the manifest it polls while playing) is authenticated by that token instead of the URL. Two things follow: an expiring link never interrupts a viewer who is already watching, and a token lifted from one viewer's player is tied to that one session.
POST /api/play/session -> 201 { sessionId, sessionToken, liveness }
POST /api/play/heartbeat x-playback-session: <sessionToken>
410 session_expired quiet longer than the grace: start again with a fresh signed URL
410 session_disconnected ended by you, an IP block or your authorization server: do not retry
A viewer counts as online while heartbeats keep arriving within 30 seconds, and any single session can be looked up and disconnected by its session id. HTTP-FLV and fMP4 delivery carries no session, so there the signed URL is the only gate and every re-pull is a new start: prefer WebRTC playback for streams you need to protect.
3. Your own authorization callback
For business rules a URL cannot express (is this account paid up, is it watching from two places), turn on an authorization server. After each playback session starts, a signed playback.session.started event is POSTed to your HTTPS endpoint with the stream, the viewer id, and the viewer's IP, country, network and browser. Answer HTTP 403, or JSON { "allow": false }, and that session is disconnected.
// Verify before trusting: X-Streaming-CDN-Signature is
// "sha256=" + base64url(HMAC_SHA256(callbackSecret, timestamp + "." + rawBody))
const event = JSON.parse(rawBody);
const allowed = await accountMayWatch(event.playback.viewerId, event.playback.streamName);
return Response.json(allowed ? { allow: true } : { allow: false, reason: "policy_denied" });
Reject timestamps outside a five-minute window and deduplicate X-Streaming-CDN-Event-Id to stop replays. The timeout is configurable from 250 to 10,000 ms (default 2,000 ms) and fails open, so a slow endpoint never blocks paying viewers.
4. Referer and Origin allowlists
List the pages allowed to embed the player. Requests from any other site's page are refused, which stops the most common case: someone embedding your player or stream on their own page. Each playback domain chooses a mode: off, Origin/Referer only, signed URL only, or both checks.
example.com # exact hostname
*.example.com # subdomains only; add example.com separately for the apex
5. Request-source policies
Real viewers come from home and mobile networks; most re-streaming scrapers run in data centers. A request-source policy classifies each request by the network it comes from and lets you log or refuse data-center sources per playback domain. Start in log mode, look at what it would have refused, then turn on refusal.
6. Address blocking
When a specific source keeps pulling your stream, block its addresses. Request logs record every playback and publish, and can be exported as CSV to find the source.
7. Protect ingest too
Protection is not only for viewers. Require a Stream Key on each ingest domain, and allowlist the publishers' public IP addresses where they are fixed, so nobody can publish into your channel. Each key's secret is shown once; if one leaks, revoke it and create a new one, and the old key is refused with 401 invalid_stream_key on the next publish.
What not to do
Do not cap how many times or how long legitimate viewers may watch to fight abuse: that turns away the audience you are paying to reach. Use the layers above, which target the abusers, not the viewers.
On Streaming CDN
Every customer sets these on its own playback and ingest domains in the console: signed URLs, Referer/Origin allowlists, an authorization server, request-source policies, address blocking, Stream Keys and publisher IP allowlists. Playback and publish request logs can be exported as CSV.