Menu

install_ubuntu_node

Dirk van der Walt

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.

Installing 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 python-software-properties python g++ make
    sudo add-apt-repository ppa:chris-lea/node.js
    sudo apt-get update
    sudo apt-get install nodejs
    
  • We need to install the following Node.js packages globally.

    sudo npm -g install tail
    sudo npm -g install socket.io
    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.

    • If you are running Nginx; the sample start-up script is found under /usr/share/nginx/www/cake2/rd_cake/Setup/Node.js/nodejs-socket-io

      sudo cp /usr/share/nginx/www/cake2/rd_cake/Setup/Node.js/nodejs-socket-io /etc/init.d
      sudo chmod 755 /etc/init.d/nodejs-socket-io
      sudo update-rc.d nodejs-socket-io start 80 2 3 4 5 . stop 20 0 1 6 .
      
    • If you are running Apache; the sample start-up script is found under /var/www/cake2/rd_cake/Setup/Node.js/nodejs-socket-io

      sudo cp /var/www/cake2/rd_cake/Setup/Node.js/nodejs-socket-io /etc/init.d
      sudo chmod 755 /etc/init.d/nodejs-socket-io
      sudo update-rc.d nodejs-socket-io defaults
      

Test the Node.js server

  • Start the server and confirms that it is running on port 8000 by requesting the client side Socket.io library.

    sudo /etc/init.d/nodejs-socket-io start
    
  • 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
    
  • Request the following URL and ensure that you are served with some JavaScript. (Replace the IP Address to that of the RADIUSdesk server) http://127.0.0.1:8000/socket.io/socket.io.js

Things to remember

  • 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.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.