Join chat

Creating Logux Proxy

In this guide, we will create the Logux proxy between WebSocket and your back-end server.

If you like Node.js and want the best performance, you can try to move business logic directly to Logux Server. Or you can keep high-performance parts in Logux Server and send others to the back-end HTTP server.

Creating the Project

Install Node.js (version 10.0 or later).

Create a directory for a project. We will use server-logux name.

mkdir server-logux
cd server-logux

Create package.json with:

  "name": "server-logux",
  "private": true,
  "main": "index.js",
  "scripts": {
    "start": "node index.js"

Install Logux Server:

  • npm i @logux/server

    Create index.js with:

    const { Server } = require('@logux/server')
    const server = new Server(
      Server.loadOptions(process, {
        subprotocol: '1.0.0',
        supports: '1.x',
        root: __dirname

    Create .env file. Put this file to .gitignore. Set your local back-end server URL and secret:


    The proxy is ready. You can start it with:

  • npm start

    To stop the server press Command+. on Mac OS X and Ctrl+C on Linux and Windows.

    The proxy will send the user’s authentication request, Logux subscriptions, and actions to http://localhost:3000/logux. Your back-end can send actions to the client by sending an HTTP request to http://localhost:31338.

    Back-end Server

    Now we need to prepare back-end to receive requests from Logux proxy server.

  • logux_rails gem adds Back-end Protocol support to Ruby on Rails.

    Go to your Ruby on Rails application folder:

    cd ../server-rails

    Add gems to Gemfile and call bundle:

    gem 'logux_rails'
    gem 'dotenv-rails', groups: [:development, :test]

    Create .env file. Put this file to .gitignore.


    Create config/initializers/logux.rb file:

    Logux.configuration do |config|
      config.password = ENV['LOGUX_CONTROL_PASSWORD']
      config.logux_host = ENV['LOGUX_URL']
      config.auth_rule = lambda do |user_id, token|
        # Allow only local users until we will have a proper authentication 

    Add Logux to config/routes.rb:

    Amplifr::Application.routes.draw do
      mount Logux::Engine, at: '/'