RADIUSdesk

Install Node.js on Ubuntu 16.04

Introduction

  • Node.js is part of the next generation web servers that is small; fast and super efficient.
  • Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
  • You can read more about Node.js on their website. http://nodejs.org/
  • The reason we are interested in Node.js is because it supports Websocket. Websocket is a reasonably new technology that is supported by the latest versions of all the major browsers which allows you to display data in real-time.
  • You can read more about Websocket on their website. http://www.websocket.org/
  • We will make use of Socket.IO as a wrapper to Websocket which runs on Node.js to read the log file and debug output of FreeRADIUS in real-time.
  • You can read more about Socket.IO on their website. http://socket.io/
  • So to summarise : Node.js→Websocket→Soket.IO→Client.

Install Node.js and dependencies

  • Install the latest Node.js. This package will also include the npm package manager for Node.js.
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
  • We need to install the following Node.js packages globally.
  • Note that we are using an older version of socket.io (0.9.x) instead of the latest 1.x.
  • Also note that there might be some warings during the install of these packages. Thats normal.
sudo npm -g install tail
sudo npm -g install socket.io@0.9.x
sudo npm -g install connect
sudo npm -g install mysql
sudo npm -g install forever

Add start-up script

  • Everything is now installed that we will need to enable us to serve the FreeRADIUS log file in real-time using Node.js, Websocket and Socet.IO.
  • We need to install a start-up file, start the Node.js server up and confirm that it works.
    • The sample start-up script is found under /usr/share/nginx/html/cake2/rd_cake/Setup/Node.js/.
#The systemd startup file
sudo cp /usr/share/nginx/html/cake2/rd_cake/Setup/Node.js/nodejs-socket-io.service  /lib/systemd/system/
 
# add a sym link to node
sudo ln -s /usr/bin/nodejs /usr/bin/node
 
#Enable it
sudo systemctl enable nodejs-socket-io.service
 
#Start it
sudo systemctl start nodejs-socket-io.service

Test the Node.js server

  • Confirm that it is running on port 8000 by requesting the client side Socket.io library.
  • Confirm it is running by checking the log file output:
sudo cat /var/log/nodejs-socket-io.log
#Result in....
info: socket.io started
Up and running on port 8000

Things to remember about Websocket

  • Websocket is not supported in IE version 9 and below.
  • Remember that this is running on port 8000 and some firewalls may block it.
  • You are welcome to alter the port on which Node.js serve by editing the /rd_cake/Setup/Node.js/Logfile.node.js file.
  • The start-up script calls Logfile.node.js during start-up. Depending on the web server you run; the absolute path of this script will change accordingly. Be sure to update this script as well if you change servers (Nginx VS Apache).
  • Although this Node.js server serves the FreeRADIUS log file; it will only be visible if the requester provides the token belonging to root. All other users will not be allowed to see this log file through the Node.js server.

Next steps

  • If you are simply looking for a RADIUS server; you are done.
  • If you are deploying CoovaChilli Captive Portals or Mikrotik Hotspots you must try the Dynamic Login Pages (optional but recommended).
  • If your server has two network cards and you want to install CoovaChilli on it as a captive portal; follow these instructions: