Skip to content

Install and startup notifications (Advanced Install)

Faraday has the ability of send notifications thru websockets, (This is also needed for using Agents).

To proper configure websockets in an on-prem install you should follow the guide.

Architecture when using Websockets:

Figure 1:

flowchart TD A[Websockets server] -->|notification|endpoint B[Faradayserver]-->|frontend statics|port-443 C{NGINX} C -->|websockets endpoint| D[websockets-server] C -->|any other endpoint| E[Faraday-server]

Install Redis and NGINX:

sudo apt install redis

sudo apt install nginx

Configuring Redis

To start working with redis, it is needed to modify the file inside config/server.ini in:

[faraday_server]


redis_session_storage = 127.0.0.1

The config file is in: /home/{usr}/.faraday/config/server.ini

Configuring Nginx

We use this configuration file:

map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }

server {
    listen 443 ssl; 
    server_name faraday.local;
    client_max_body_size 500M;
    #ssl on;
    ssl_session_cache shared:SSL:50m;
    ssl_certificate /etc/ssl/faraday.crt;
    ssl_certificate_key /etc/ssl/faraday.key;


    location / {
        alias /nix/{path-to-statics}/frontend/www/;
    }
    location /_api/ {

        proxy_pass http://127.0.0.1:5985/_api/;
        #proxy_redirect http:// $scheme://;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Ssl on;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    location /websockets {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_pass http://127.0.0.1:9000/;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $connection_upgrade;
      #proxy_read_timeout 86400;
    }

    location /_api/wsocket/v1/ {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_pass http://127.0.0.1:5000/_api/wsocket/v1/;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $connection_upgrade;
      #proxy_read_timeout 86400;
    }

}

The next step is place it in /etc/nginx/sites-available

Generating the certificates

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/faraday.key -out /etc/ssl/faraday.crt

The field Common Name should be the same as the FQDN, in our case faraday

Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:faraday.local
Email Address []:
  • Create the alias inside the file we point front on location / with the path on where the static files are.

  • Section location inside the nginx file (no need to change it)

    location / {
        alias /home/faraday/faraday/faraday/frontend/www/;
        }
    

  • Create symlinks for sites-enabled to sites-avalaible

sudo ln -s /etc/nginx/sites-available/faraday /etc/nginx/sites-enabled/faraday

  • Restart Nginx

sudo systemctl restart nginx

  • Add the entries to server.ini for faraday, in [faraday-server] this will define the websockets fqdn that we used in the nginx
[faraday-server]
...
websocket_server_fqdn = https://faraday.local
websocket_server_port = 5000
notifications_enabled = true
  • We startup the websockets server

faraday-websocket-server

so after this configuration locally you should see http://faraday.local with websockets up and running.

in case faraday.local is not resolved check on /etc/hosts for the line

127.0.0.1 faraday.local

We highly recommend you to check our First Steps guide.