Skip to content

Server configuration

Alexey Litivnov edited this page Nov 15, 2018 · 1 revision

Contents

Machine characheristics

We're using Debian 9.5 Jessie x64

Processor: Intel(R) Xeon(R) CPU E5-2630L v2 @ 2.40GHz
RAM: 8 GB
SSD: 160 GB

So, there's no HDD, because of high speed need.

Installing dependencies

To prepare your server for launching any kind of things from our repositories there are some packages should be installed.

NodeJS

We will install Node using a PPA.

Let's first update the local package index and install curl, which you will use to access the PPA:

sudo apt update
sudo apt install curl

Next, let's install the PPA in order to get access to its contents. From your home directory, use curl to retrieve the installation script for your preferred version, making sure to replace 10.x with your preferred version string (if different):

cd ~
curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh

Run the script under sudo:

sudo bash nodesource_setup.sh

The PPA will be added to your configuration and your local package cache will be updated automatically. After running the setup script, you can install the Node.js package in the same way you did above:

sudo apt install nodejs

To check which version of Node.js you have installed after these initial steps, type:

nodejs -v

The nodejs package contains the nodejs binary as well as npm, so you don't need to install npm separately.

npm uses a configuration file in your home directory to keep track of updates. It will be created the first time you run npm. Execute this command to verify that npm is installed and to create the configuration file:

npm -v

In order for some npm packages to work (those that require compiling code from source, for example), you will need to install the build-essential package:

sudo apt install build-essential

You now have the necessary tools to work with npm packages that require compiling code from source.

Yarn

On Debian or Ubuntu Linux, you can install Yarn via our Debian package repository. You will first need to configure the repository:

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

Then you can simply:

sudo apt-get update && sudo apt-get install yarn

If using nvm you can avoid the node installation by doing:

sudo apt-get install --no-install-recommends yarn

Lerna

The last thing you need (if using monorepo) lerna. That's a tool for managing JavaScript projects with multiple packages.

The only thing you should do:

npm install --global lerna

Nginx configurations

We're using Nginx in proxying and rooting.

Here're things you should add to your configs:

nginx.conf:

proxy_connect_timeout TIME;
proxy_connect_timeout TIME;
proxy_send_timeout    TIME;
proxy_read_timeout    TIME;
send_timeout          TIME;
fastcgi_read_timeout  TIME;
keepalive_timeout     TIME;
client_header_timeout TIME;
client_body_timeout   TIME;

Your server config file (for both socket and http):

    location /socket {
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_set_header Authorization $http_authorization;
        proxy_pass http://your_host_ip:ws_port;
   }

   location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Authorization $http_authorization;
        proxy_http_version 1.1;
        proxy_pass_request_headers on;
        proxy_set_header Connection "keep-alive";
		proxy_store off;
		proxy_pass http://your_host_ip:rest_port;
    }

s

Clone this wiki locally