Skip to content

Full-fledged media streaming server with OpenResty and rtmp module

License

Notifications You must be signed in to change notification settings

duythongle/k8s-openresty-streaming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

k8s-openresty-streaming is a full-fledged media streaming server with OpenResty and rtmp module for Kubernetes

Features

Prerequisites

Usage

Quickstart with Docker

SSH to your server and run

# Clone this repo
git clone https://github.com/duythongle/k8s-openresty-streaming.git  
# Run image and mount config files for later editing
docker run -dit --name my_streaming_server \
  -p 80:80 \
  -p 443:443 \
  -p 1935:1935 \
  -v ~/k8s-openresty-streaming/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf \
  thongld/k8s-openresty-streaming:alpine-fat \
  openresty -g "daemon off;"

Then your browser should display OpenResty welcome home page at http://streaming_server_ip/ . Later on, just edit the mounted nginx.config file at ~/k8s-openresty-streaming/nginx.conf for your needs and apply changes with command below

sudo docker exec my_streaming_server sh -c "openresty -t && openresty -s reload"

Quickstart with Kubernetes

# Coming soon...

Then go to http://streaming_server_ip/ to view openresty welcome home page

More...

  • GeoIP REST API can be accessed at public location /api/geoip. Ex.: http://streaming_server_ip/api/geoip/location/8.8.4.4. Read more geoip api at Telize GeoIP REST API
  • Point your DNS to the server ip and see the magic of Auto SSL happens at https://streaming_server_domain

Note: Let's Encrypt has rate limits and the first https request for a domain may take a few seconds to complete

  • nginx rtmp module has default application endpoint my_live_stream. You can push your live stream to the server via url: rtmp://streaming_server_ip_or_domain:1935/my_live_stream/my_stream_name and playback with hls url http://streaming_server_ip_or_domain/hls/my_stream_name

Building from source

git clone https://github.com/duythongle/k8s-openresty-streaming.git
cd k8s-openresty-streaming
docker build -t openresty-streaming-server -f alpine-fat/Dockerfile .
# Then run the image
docker run -dit --name my_streaming_server \
  -p 80:80 \
  -p 443:443 \
  -p 1935:1935 \
  -v ~/k8s-openresty-streaming/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf \
  openresty-streaming-server \
  openresty -g "daemon off;"

TODO

  • 12factor ready
  • K8s ready
  • Helm support
  • Auto reload Nginx when .conf changes