Flussonic Media Server documentation

It's a very often question, what parameters Flussonic passes to an auth backend.

Parameters themselves are described in article about authorization.

But how to see specific values​​?

Of course, it depends on the technology used. We can not describe all possible programming languages ​​and operating systems. So in this article we'll create a login script in PHP, and run it on Ubuntu operating system, using the built-in PHP web server.

Installing PHP with built-in web server Anchor Anchor x2

Built-in web server is not designed to work in a real production environment, and can be used for testing purposes only. If you need to use this script in production, you need to install and configure nginx, apache, fpm and so forth. It's difficult and time consuming, so this process is not described in this article.

As stated in the PHP documentation, embedded web server is only available starting with 5.4.0 version.

Unfortunately, this new version may not be among the available packages. As an example, I'll show you how to install the latest PHP on Ubuntu using PPA. You should run this commands in a command prompt (console) of your server:

sudo apt-get install software-properties-common python-software-properties
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5

Warning: if you do not trust the "ppa: ondrej / php5" repository, you have to find some other way to install a fresh PHP on your system. We (Erlivideo/Flussonic) take no responsibility for the content of this PPA.

Next we have to check that PHP is really installed. In a command prompt you may run php -v. You should see something like this:

PHP 5.5.16-1+deb.sury.org~trusty+1 (cli) (built: Aug 25 2014 10:24:59)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans

Scripting Anchor Anchor x2

Save this script in any convenient location on your hard drive. For example, if the user you are using is called "flussonic", you can create the /home/flussonic/phproot directory and create a new script file: /home/flussonic/phproot/notify.php.

At the beginning of the script you have to to edit two settings, LOG_FILE (location of a resulting file, you will read it later) and AUTH_DURATION (how often Flussonic will access backend with new requests).


/* ========== SETTINGS ========== */
$LOG_FILE = '/tmp/notify.log';
/* ============================== */

function array_read($array, $seperator = ', ', $ending = ' and '){
      $opt = count($array);
      return $opt > 1 ? implode($seperator,array_slice($array,0,$opt-1)).$ending.end($array) : $array[0];

function logme($tolog) {
    global $LOG_FILE;
    $file = $LOG_FILE;
    // Write the contents to the file,
    // using the FILE_APPEND flag to append the content to the end of the file
    // and the LOCK_EX flag to prevent anyone else writing to the file at the same time
    file_put_contents($file, $tolog, FILE_APPEND | LOCK_EX);

function logmeln($tolog) {

function detectRequestBody() {
    $rawInput = fopen('php://input', 'r');
    $tempStream = fopen('php://temp', 'r+');
    stream_copy_to_stream($rawInput, $tempStream);

    return $tempStream;

function getRequestBody() {
    return file_get_contents('php://input');

function logRequest() {
    global $AUTH_DURATION;

    logmeln("BEGIN LOG");
    logmeln("user agent");
    logmeln(print_r($_POST, true));
    logmeln(print_r($_GET, true));
    logmeln(print_r($_SERVER, true));
    logmeln("REQUEST BODY");
    logmeln(print_r(getRequestBody(), true));
    logmeln("END LOG");

    header("Status: 200");
    header("HTTP/1.0 200 OK");
    header("X-AuthDuration: ".$AUTH_DURATION);



Let's say your file have this name: /home/flussonic/phproot/notify.php

Then you should run this commands in a command line of your server:

cd /home/flussonic/phproot
php -S localhost:8000

If the server is started normally, it should respond with something like this:

PHP 5.5.16-1+deb.sury.org~trusty+1 Development Server started at Thu Sep 25 20:55:15 2014
Listening on http://localhost:8000
Document root is /home/flussonic/phproot
Press Ctrl-C to quit.

Now all requests to this URL: http://localhost:8000/notify.php will be logged to this file: /tmp/notify.log.

Enabling authorization in Flussonic Anchor Anchor x2

Add your static stream to the configuration file. As an "auth" directive parameter you should use the URL, which is served by the built-in server (http://localhost:8000/notify.php).

stream myvideo {
  url tshttp://videoserver/videostream;
  auth http://localhost:8000/notify.php;

Apply changes of the configuration file /etc/init.d/flussonic reload.

Testing Anchor Anchor x2

Log in to the web interface of Flussonic and try to watch the video directly from the web interface.

At this time new records should start to appear in the log file (for example, /tmp/notify.log).

New entries conveniently observed in a console with this command: tail -f /tmp/notify.log.