Skip to content

Instantly share code, notes, and snippets.

@woganmay
Last active March 6, 2021 18:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woganmay/de9bf6da8d23117e3f932c546f0581ae to your computer and use it in GitHub Desktop.
Save woganmay/de9bf6da8d23117e3f932c546f0581ae to your computer and use it in GitHub Desktop.
Setting up nginx + rtmp

This was all done on a Debian Linux server.

Speedtest

Install speedtest-cli by:

sudo easy_install speedtest-cli

That gives you a one-line command to run up/down tests via speedtest.net. To hit a specific server, check the main list at https://www.speedtest.net/speedtest-servers.php and provide the ID to test against:

speedtest-cli --server 123

Nginx + RTMP

You'll need to compile NGINX yourself. If this server will be doing nothing else, it's better to uninstall the repo version and just use the setup for streaming.

sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev
wget http://nginx.org/download/nginx-1.13.1.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
tar -zxvf nginx-1.13.1.tar.gz
unzip master.zip
cd nginx-1.13.1
./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master
make
sudo make install

That will build a version of nginx with rtmp support enabled. To use it, edit the local nginx config file:

sudo nano /usr/local/nginx/conf/nginx.conf

Remove the http block (if you're doing this single-purpose) and setup a RTMP block:

rtmp {
  server {
    listen 1935;
    chunk_size 4096;

    allow publish 127.0.0.1;
    deny publish all;

    application live {
        live on;
        record off;
        push rtmp://[...];
    }
  }
}

The push directive will be the full URL to the ingest server, including your stream key.

Save that, then invoke your custom-built nginx:

sudo /usr/local/nginx/sbin/nginx

To stop the server, run:

sudo /usr/local/nginx/sbin/nginx -s stop

Upload from OBS/etc

The URL to stream to will be:

rtmp://[ip address]/live

The stream key can be "test", or anything else.

Bonus: bwm-ng

If you want to monitor traffic in a very simple way:

sudo apt-get install bwm-ng
bwm-ng

It neatly shows Rx/Tx on all interfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment