analytics

Installation of DSM Management Suite backend on an Ubuntu server 18.04

Installation of DSM Management Suite backend on an Ubuntu server 18.04

Installation of DSM Management Suite backend on an Ubuntu server 18.04

Download a Linux server version for installation. The LTS version 18.04 of Ubuntu Server is currently recommended. Alternative distributions and versions are also possible, but they work somewhat differently than in this manual. Create a new virtual machine on your hypervisor.

It is recommended to give the virtual machine at least 2 CPUs and 4 GB RAM. Depending on how long you want to keep the data, you should choose your hard disk size. For a productive environment with 50 computer objects on a data retention period of 14 days including backup of the MySQL database, 50 GB of storage space should already be available. More like is always better. Adjust your storage space requirements depending on your environment and your backup method.

In this guide, for reasons of simplicity, we install MySQL (or MariaDB) on the same server as the DSM Management Suite backend. In practice, you should use your own server for the database.

1. Installation of Ubuntu Server 18.04

Install an Ubuntu server according to your ideas. It is recommended to install the following services directly during the basic installation, as we will not explicitly deal with the subsequent installation of the software packages in these instructions: Installation is optional:

  • OpenSSH

2. Install the necessary packages

sudo apt-get update
sudo apt-get install apache2
sudo apt-get install mariadb-server
sudo apt-get install curl

wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

sudo dpkg -i packages-microsoft-prod.deb
sudo add-apt-repository universe

sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-2.2

sudo a2enmod headers
sudo a2enmod rewrite
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod ssl
sudo systemctl restart apache2

Configure MySQL

Connect to your MySQL server

sudo mysql -u root -p

Create a new database for DSM Management Suite.

In this manual we use the database name db_dsmpro.

CREATE DATABASE db_dsmpro;

Next we import the initial database structure

mysql -u root -p db_dsmpro < /home/Downloads/db.sql

Create user:

CREATE USER 'dsmpro'@'localhost' IDENTIFIED BY 'dsmpro_user_password';

Instead of “dsmpro_user_password” use a suitable and strong password.

Now we give the user rights to the database:

GRANT ALL PRIVILEGES ON db_dsmpro.* TO 'dsmpro'@'localhost';

Leave the MySQL CMD with:

exit

Configure web server / relay proxy for backend

Depending on how you want to make your backend available, you should adapt your Apache configuration. In this example we publish the backend on our server via the DNS name (A-Record) “api.servername.de”. HTTP inquiries are then answered from this address or subdomain and forwarded to our backend (local host: 5000) (relay proxy). The backend runs on the basis of dotnet core. Kestral service as a web server, which everyone still accepts requests to Localhost: 5000. For the relay proxy to work, we have to allow in the Apache configuration that all headers used by the backend are forwarded (POST, GET, OPTIONS etc.).

A later chapter shows how to use Certbot to route website traffic to HTTPS. The redirection from HTTP to HTTP in the configuration file then does Certbot for us.

We create a new configuration file in the Apache configuration directory.

cd /etc/apache2/sites-available
nano /etc/apache2/sites-available/dsmpro.conf

Insert the following content and adapt the bold lines to your A-Record

<VirtualHost *:80>
  ServerName api.servername.de
  ServerAlias api.servername.de
  ProxyPreserveHost On
  ProxyPass / http://localhost:5000/
  ProxyPassReverse / http://localhost:5000/
  Header set Access-Control-Allow-Origin "*"

  Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"

  Header set Access-Control-Allow-Headers "Accept,Accept-Charset,Accept-Encoding,Accept-Language,Connection,Content-Type,Cookie,DNT,Host,Keep-Alive,Origin,Referer,User-Agent,X-CSRF-Token,X-Requested-With,Authorization"

  Header set Access-Control-Allow-Credentials true
</VirtualHost>

<Proxy http://localhost:5000>
  Order deny,allow
  Allow from all
</Proxy>

Install DSM Management Suite backend

Upload the dsmpatchreportingapi.dll to your server in the directory / var / www / html / dsmapi / dsmpatchreportingapi .dll. The best way to do this is via SSH.

Note: In the next versions the DLL will be called dsmmanagementsuite.dll.

Next we create a daemon (service) which starts the backend when the server starts

Create a daemon (service definition file)

sudo nano /etc/systemd/system/dsmapi.service

insert the following:

[Unit]
Description=DSM Management Suite API
[Service]
WorkingDirectory=/var/www/html/dsmapi
ExecStart=/usr/bin/dotnet /var/www/html/dsmapi/dsmpatchreportingapi.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dsmpatchreporting
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target

If your configuration does not use the www-data user, the user defined here must first be created and given proper ownership of the files.

Activate the service

sudo systemctl enable dsmapi.service
sudo systemctl start dsmapi.service

Activate firewall or open ports

sudo apt-get install ufw
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable

Additionally install and configure DSM Patch Reporting Web UI

You can also install the WebUI on the server to have a front end for the application via HTTPS. The web application is an Angular (JavaScript) application that connects to the API (backend: api.servername.de) and queries the data. It is recommended to install NodeJS and Angular-CLI so that you can build the application yourself. The WebUI can also be installed on another server. In this description we will install the application on the same server. Again we use a virtual host entry in Apache for www.servername.de

Install additional requirements for Web UI

sudo apt-get install git
sudo apt-get install npm
sudo npm install -g angular-cli

Create directory for Web UI

cd /var/www/html/dsmwebui

WebUI web server adjustments

<VirtualHost *:80>
DocumentRoot "/var/www/html/dsmwebui/dist/webui"
ServerName www.servername.de
 <Directory "/var/www/html/dsmwebui/dist/webui">
    AllowOverride None
 </Directory>
</VirtualHost>

Download the current WebUI source code with Git

In order to always get the current source code, it makes sense to clone the repository with Git. If you don’t want to use Git, manually download the Git repository as a zip file and copy the data into the / var / www / dsmwebui directory

Use cd to change to the directory for the web application:

cd /var/www/html/dsmwebui

Now we clone the Git repository

>git clone https://github.com/…```

** Now we download all dependencies (Node_Modules) with NPM: **

npm install

Adjust configuration file: We open the Environment.ts file and adjust the connection settings to the API (backend).

nano src/envirionments/environment.ts

With BaseURL, you now replace the address with the address of your DSM Management Suite backend. Localhost is not possible here because JavaScript is executed on the client side. Any computer trying to access the frontend would find the backend on the local system.

export const environment = {
production: false,
baseUrl: 'http://localhost:5000/api'
};

Change in

export const environment = {
production: false,
baseUrl: 'http://api.servername.de/api'
};

Now we can build the application

npm run build

Configure SSL

Optional: Install Certbot for SSL encryption

sudo apt-get install software-properties-common

sudo add-apt-repository ppa:certbot/certbot

sudo apt install python-certbot-apache

sudo certbot --apache -d api.servername.de -d www.servername.de

Did you like the post?

Become a Patreon and support my work. As a thank you, you will receive exclusive articles, be listed as a sponsor for all my open source projects (do-follow backlink) and get access to exclusive articles.
Don't fancy Patreon? You can also easily support me if you like this article or share it on social media. Thank you!