Phin Tech docs Rabbit Ears Manager in the store →

IPTV relay: provider traffic through PIA, by country

Draft, 2026-09-27. Nothing here is built yet; two decisions are still open (see Open decisions).

Why #

The apps play video through AVPlayer, which can't be pointed at a proxy per request. So video has to come to the Apple TV from something that already fetched it through the VPN: a relay on the home network.

The shape #

                          ┌─▶ gluetun-es (PIA Spain)  :8888 ─▶ es.uhdp.top, Spanish channels
Apple TV ─▶ iptv-relay ───┼─▶ gluetun-uk (PIA UK)     :8888 ─▶ UK channels
                          └─▶ direct ────────────────────────▶ everything else

What the relay does #

Request from the app Relay
player_api.php (login, categories, guides, connection counts) Forwards it as is. Your username and password pass through; the relay keeps no credentials.
/live/…/123.m3u8 (HLS) Fetches it, follows the provider's redirect to its token server, and rewrites every segment address in the playlist to point back at the relay, so segments take the same route.
/live/…/123.ts, /timeshift/…, /movie/…, /series/… Streams them through as they come (no buffering the whole thing), passing Range along so On Demand seeking works.
xmltv.php, get.php Forwards them.
/healthz Each route's state: tunnel up, exit country and IP.

Routing by country #

Each request goes one way:

  1. By server. A server tied to a country always goes through it: es.uhdp.top → Spain, gr.uhdp.top → Greece, it.uhdp.top → Italy.
  2. By channel. For a stream, the relay looks the stream id up in the provider's channel list (fetched and kept a day, like the apps do) and reads the region off its name: "UK: BBC ONE" → UK, "ES| LA 1" → Spain, the same parsing as ChannelName.region. A stream's segments follow its playlist.
  3. Rules override both: "stream 4411 via Spain", "category US Sports direct".
  4. Everything else goes direct, or through a default route if one is set. API calls and guides don't pay VPN latency for nothing.

A region with no exit set up goes direct. Adding a country is one gluetun container and one line of config.

Config sketch #

listen: :8080
routes:                         # exits, by name
  es: http://gluetun-es:8888
  uk: http://gluetun-uk:8888
default: direct
providers:
  trex:
    servers: [http://vpn.uhdp.top, http://tv.wd.uhdp.top, http://es.uhdp.top, http://gr.uhdp.top, http://it.uhdp.top]
    server_routes: { es.uhdp.top: es, gr.uhdp.top: gr, it.uhdp.top: it }
    by_region: true             # "UK: …" → uk, "ES| …" → es, when that route exists
    rules:
      - { stream: 4411, route: es }
      - { category: "US SPORTS", route: direct }

The relay tells logins apart by username, so one relay serves every provider.

In the apps #

Almost nothing changes: a login's servers are just URLs.

Open decisions #

  1. How a stream's country is chosen.
    • (a) Automatically from the region in its name, with rules for exceptions (the config above). No app changes. Recommended.
    • (b) Picked per channel in the Manager ("Route: Direct / Spain / UK"), synced, with the app putting the route in the URL (/es/live/…). Most control; app work, set on every channel.
    • (c) (a), with a per-feed override in the Manager for the odd channel.
  2. Where the relay's code lives.
    • (a) This repo, under Relay/, its own Go module and Dockerfile: it only serves these apps, and changes with them. Recommended.
    • (b) A new repo, phin-tech/iptv-relay, with its own CI building the image.
    • (c) The homelab GitOps repo.

Trying it #

  1. Locally first: a Compose file with gluetun-es (PIA Spain) and the relay, PIA login in a local .env.
  2. Point a Debug Manager's trex login at http://localhost:8080 and check: the login, a live HLS channel, Earlier Shows, a movie with seeking, the connection count at tune-in, and whether es.uhdp.top answers through Spain.
  3. Then the homelab, via the deploy-to-homelab setup.

Alternatives looked at #