# hls-restream-proxy

> Self-hosted HLS proxy that injects headers and rewrites playlists for Jellyfin, Emby, Plex and other media servers to play IPTV streams requiring specific HTTP headers.

- **Category:** Media Streaming
- **Licence:** MIT
- **Open source:** oss
- **Languages:** Python, Shell
- **Platforms:** Docker, Docker Compose, Build from Source, Systemd
- **Tags:** Proxy, Streaming, Homelab, Plex, Emby, Jellyfin, Hls, Live tv, Iptv, M3u, M3u8, Restream, Selfhosted

## Description

hls-restream-proxy is a lightweight toolkit that sits between self-hosted media servers (Jellyfin, Emby, Plex via Threadfin/xTeVe) and upstream HLS/IPTV sources that require specific HTTP headers like User-Agent and Referer. It consists of a Python reverse proxy (hls-proxy.py) that adds headers and rewrites m3u8 playlists so segment requests also pass through it, a bash script (refresh-m3u.sh) that scrapes source pages to generate an M3U playlist with stable proxy URLs, and a detector tool (detect-headers.sh) to automatically discover which headers a stream needs. The proxy auto-learns Referer headers per upstream host and caches m3u8 URLs for an hour to handle token refresh transparently. It runs on Python 3.8+ with no pip dependencies, and can be deployed via Docker, Docker Compose, manual execution, or systemd user services. The project is MIT-licensed and aimed at homelab users running personal media servers.

## Links

- [Homepage](https://github.com/pcruz1905/hls-restream-proxy)
- [Docker](ghcr.io/pcruz1905/hls-restream-proxy)
- [GitHub Repository](https://github.com/pcruz1905/hls-restream-proxy)

---
Source: https://selfhost.directory/project/hls-restream-proxy