Live Streaming Server Setup
Published on , 658 words, 3 minutes to read
I have set up my own RTMP server that allows me to live stream to my own infrastructure. This allows me to own my own setup and not need to rely on other services such as Twitch or YouTube. As a side effect of doing this, I can enable people who use my streaming server to use picture-in-picture mode in iPadOS without having to hack the streaming app, among other things.
This is part of my 2020 goal to reduce my dependencies on corporate social platforms as much as possible.
I chose to do my setup with a few key parts:
I chose to use docker-nginx-rtmp as a pre-packaged solution for my RTMP server. This means I could set it up to ingest via my WireGuard VPN with very little work. Here is the docker command I run on my VPN host:
$ docker run \
--restart always \
-p 10.77.0.1:1935:1935 \
-p 127.0.0.1:8080:80 \
--name rtmp-server \
This starts my RTMP server in a container named
rtmp-server and automatically
restarts it when it goes down. The IP address in the first
is the VPN IP address of my main VPN server. This makes me have to be behind my
VPN in order to stream to my server, given the total lack of authentication
that's involved in RTMP.
I have a custom stream page set up on my server that has a
friendly little wrapper to the video player. Here is the source
code for it. It's very short and easy to follow. I have these files at
/srv/http/home.cetacean.club on my VPN server.
This wraps hls.js so that users on every browser I care to support can watch the stream as it happens.
In order to expose the stream data to the world, I use Caddy as a reverse proxy. Here is the configuration that I use for Caddy:
# Set up automagic Let's Encrypt
# Proxy the playlist, stream data
# and statistics to the rtmp server
proxy /hls http://127.0.0.1:8080
proxy /live http://127.0.0.1:8080
proxy /stat http://127.0.0.1:8080
# make /stream.html show up as /stream
# serve data out of /srv/http/home.cetacan.club
# you can put your HTTP document root
# anywhere you want, but I like it being
For more information on the Caddy configuration directives used here, see the following:
Live streaming like this uses ABSURD amounts of bandwidth. Do not set this up on a server that has limited bandwidth. If you need a server that has unlimited bandwidth, check out SoYouStart. It's what I use.
There isn't a good story for recording or announcing streams to this server automatically. I don't consider this a problem, as links can always be sent out manually on social media platforms.
I hope this little overview of my setup was informative. I'll be streaming there very irregularly, mostly as time permits/the spirit moves me. I plan to stream art, gaming and code.
Thanks for reading, have a good day.
Facts and circumstances may have changed since publication. Please contact me before jumping to conclusions if something seems wrong or unclear.
Tags: rtmp, live-streaming