Skip to content

running on digital ocean

Roman Lubushkin edited this page Aug 2, 2017 · 1 revision

Running AnyChart Node Export Server on Digital Ocean - Step by Step Guide

Creating Digital Ocean Droplet

Create Droplet

Droplet Settings

Complete Droplet Setup

Get IP!

Setup Server

Connect to server

Connect to server over ssh using IP you got from the Complete Droplet Setup step

Setup firewall

Закрываем все порты кроме тех что будем использовать при помощи дефолтной утилиты UFW 22 порт будет использоваться для SSH соединений

$ ufw allow 22
> Rules updated

80 порт будет использоваться для HTTP соединений

$ ufw allow 80
> Rules updated

443 порт будет использоваться для HTTPS соединений

$ ufw allow 443
> Rules updated

активируем firewall

$ ufw enable
> Firewall is active and enabled on system startup

Install Node.js

Нам нужно поставить latest stable version, на момент написания статьи это v6.11.2

$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
$ sudo apt-get install -y nodejs

Install Nginx

$ apt-get install nginx

Install AnyChart Node Export Server

$ npm install anychart-export-server -g
> /usr/bin/anychart-export-server -> /usr/lib/node_modules/anychart-export-server/index.js

Install ImageMagick and libRSVG

ImageMagick libRSVG

$ apt-get install imagemagick librsvg2-bin

Install Supervisor

apt-get install supervisor

Configure Server

Configuring Supervisor

Create config file

nano /etc/supervisor/conf.d/anychart-export-server.conf

Copy/paste config

[program:anychart-export-server]
command=/usr/bin/anychart-export-server
autostart=true
autorestart=true
stderr_logfile=/var/log/anychart-export-server.err.log
stdout_logfile=/var/log/anychart-export-server.out.log

Apply configuration

$ supervisorctl reread
> anychart-export-server: available

supervisorctl update
> anychart-export-server: added process group

Check Server status

$ curl http://localhost:3000/status
> ok

Configuring Nginx

Create config file

nano /etc/nginx/conf.d/anychart-export-server.conf

Copy/paste config

Replace YOU_DOMAIN with your domain name, for example, report.anychart.com

server {
    listen      80;
    server_name YOU_DOMAIN_NAME;

    gzip on;
    gzip_types text/plain text/csv application/json image/svg+xml application/pdf application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;
    charset utf-8;

    access_log /var/log/nginx/anychart-export-server-access.log;
    error_log /var/log/nginx/anychart-export-server-error.log;

    location ~ /\.ht {deny  all;}
    location ~ /.git/ {deny all;}

    location / {
            proxy_pass http://127.0.0.1:3000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
    }
}

Apply configuration

$ service nginx reload
> Reloading nginx configuration nginx

Configure DNS

Если вы используете какой-то кастомный DNS, например тот DNS где был куплен домент, то идите и смотрите там. Если нет, то вот так: