Ech0 - 00 / 00 / 00

MyMind + MindMaps Installation

In this tutorial we're going to look at how to install MyMind, which is a simple web application (HTML CSS JS) to create mindmaps

Initial Setup

We're going to setup a debian CT on proxmox:


root@mindmaps:~# wget https://raw.githubusercontent.com/ech1/serverside/master/ssh/ssh.sh ; chmod +x ssh.sh ; ./ssh.sh

This will setup key-based SSH authentication, generate the ssh keys and go get them on port 8080:


Generating public/private ed25519 key pair.
Enter file in which to save the key (/root/.ssh/id_ed25519): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_ed25519.
Your public key has been saved in /root/.ssh/id_ed25519.pub.
The key fingerprint is:
SHA256:IubhhdBEfOjtKdMtfjIDgVl/7MYOSZ3WQTRzqN1s7p0 root@mindmaps
The key's randomart image is:
+--[ED25519 256]--+
|   oo.   o=..    |
|   o+ .   o+     |
|  .=.+ o = +     |
|  o.o.+ B o +    |
|    ==oOS  o     |
|   +++B.=   .    |
|    o= =   . . . |
|      = o   . E  |
|       =         |
+----[SHA256]-----+
* ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2021-04-15 07:56:15 UTC; 1min 28s ago
     Docs: man:sshd(8)
           man:sshd_config(5)
  Process: 9249 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
 Main PID: 9250 (sshd)
    Tasks: 1 (limit: 7372)
   Memory: 1.2M
   CGroup: /system.slice/ssh.service
           `-9250 /usr/sbin/sshd -D

Apr 15 07:56:15 mindmaps systemd[1]: Starting OpenBSD Secure Shell server...
Apr 15 07:56:15 mindmaps sshd[9250]: Server listening on 0.0.0.0 port 22.
Apr 15 07:56:15 mindmaps sshd[9250]: Server listening on :: port 22.
Apr 15 07:56:15 mindmaps systemd[1]: Started OpenBSD Secure Shell server.
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
    inet 10.0.0.171/16 brd 10.0.255.255 scope global eth0
    inet6 fe80::e468:c7ff:fe64:d1ec/64 scope link 
[+] ON A REMOTE HOST RUN THE FOLLOWING:
[+] wget http://ip:8080/id25519 -O ~/.ssh/node.pkey
[+] chmod 600 ~/.ssh/node.pkey
Serving HTTP on 0.0.0.0 port 8080 (http://0.0.0.0:8080/) ...
	


[ 10.0.0.10/16 ] [ /dev/pts/1 ] [~]
→ curl http://10.0.0.171:8080




Directory listing for /


Directory listing for /



[ 10.0.0.10/16 ] [ /dev/pts/1 ] [~] → curl http://10.0.0.171:8080/id_ed25519 -----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW QyNTUxOQAAACBC4JDCtpHq1bJXiZPg142zMnQpdOXkgrbDipaewWfAFgAAAJA5jaE1OY2h NQAAAAtzc2gtZWQyNTUxOQAAACBC4JDCtpHq1bJXiZPg142zMnQpdOXkgrbDipaewWfAFg AAAECHBgET4iawSg4SYLZWH2HGOtUJ5FY/mHif/dMm6FWx30LgkMK2kerVsleJk+DXjbMy dCl05eSCtsOKlp7BZ8AWAAAADXJvb3RAbWluZG1hcHM= -----END OPENSSH PRIVATE KEY----- [ 10.0.0.10/16 ] [ /dev/pts/1 ] [~] → curl http://10.0.0.171:8080/id_ed25519 > ~/.ssh/mindmaps ; chmod 600 ~/.ssh/mindmaps % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 399 100 399 0 0 129k 0 --:--:-- --:--:-- --:--:-- 129k

Once that's done, hit CTRL+C in the CT's proxmox TTY Console to shut down the python http server, and login via ssh into your CT:


[ 10.0.0.10/16 ] [ /dev/pts/1 ] [~]
→ ssh root@10.0.0.171 -i ~/.ssh/mindmaps
The authenticity of host '10.0.0.171 (10.0.0.171)' can't be established.
ED25519 key fingerprint is SHA256:sYUwEQBCxgH/qCG4gU8I3k5/QIheGaaZ0RFzGRVt7Zk.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.0.0.171' (ED25519) to the list of known hosts.
Last login: Thu Apr 15 07:53:59 2021

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
	
root@mindmaps:~# apt install nginx git -y

Configuring NGINX



We're going to setup a very simple nginx setup for our local host:


root@mindmaps:~# vim /etc/nginx/sites-available/mindmaps.conf
	
server {
        listen 80;
        listen [::]:80;
        root /var/www/html/mymind;
	index index.html;
}

:wq

root@mindmaps:~# ln -s /etc/nginx/sites-available/mindmaps.conf /etc/nginx/sites-enabled/

root@mindmaps:~# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

root@mindmaps:~# nginx -s reload

Now that's done, let's git clone the mymind repository into /var/www/html/:


root@mindmaps:/var/www/html# git clone https://github.com/ondras/my-mind mymind
root@mindmaps:/var/www/html# chmod -R 655 mymind/
root@mindmaps:/var/www/html# chown -R www-data: mymind/
root@mindmaps:/var/www/html# ls -lash mymind/
total 388K
4.0K drw-r-xr-x 10 www-data www-data 4.0K Apr 15 08:10 .
4.0K drwxr-xr-x  3 root     root     4.0K Apr 15 08:10 ..
4.0K drw-r-xr-x  8 www-data www-data 4.0K Apr 15 08:10 .git
4.0K -rw-r-xr-x  1 www-data www-data 1.1K Apr 15 08:10 LICENSE.txt
4.0K -rw-r-xr-x  1 www-data www-data 1.5K Apr 15 08:10 Makefile
4.0K -rw-r-xr-x  1 www-data www-data  591 Apr 15 08:10 PRIVACY.txt
4.0K -rw-r-xr-x  1 www-data www-data 1.7K Apr 15 08:10 README.md
4.0K drw-r-xr-x  2 www-data www-data 4.0K Apr 15 08:10 bin
4.0K drw-r-xr-x  2 www-data www-data 4.0K Apr 15 08:10 css
4.0K -rw-r-xr-x  1 www-data www-data 2.9K Apr 15 08:10 editor.html
4.0K drw-r-xr-x  2 www-data www-data 4.0K Apr 15 08:10 examples
 36K -rw-r-xr-x  1 www-data www-data  34K Apr 15 08:10 favicon.ico
4.0K -rw-r-xr-x  1 www-data www-data 1.7K Apr 15 08:10 github.png
4.0K drw-r-xr-x  2 www-data www-data 4.0K Apr 15 08:10 icons
 60K -rw-r-xr-x  1 www-data www-data  57K Apr 15 08:10 index.html
4.0K drw-r-xr-x  2 www-data www-data 4.0K Apr 15 08:10 logo
136K -rw-r-xr-x  1 www-data www-data 136K Apr 15 08:10 my-mind.js
 92K -rw-r-xr-x  1 www-data www-data  90K Apr 15 08:10 screenshot.png
4.0K drw-r-xr-x  2 www-data www-data 4.0K Apr 15 08:10 src
4.0K drw-r-xr-x  3 www-data www-data 4.0K Apr 15 08:10 vendor
	

Once that's done, goto http://10.0.0.171/ to see the result:

After creating mindmaps you can save them:

And load them:

And that's it! However let's check out another interesting mindmapping HTML CSS JS project simply called mindmaps. We're going to update the nginx config to have port 8080 serve a http reverse proxy to http://localhost:3000 (where the npm server outputs) with the root path being in /var/www/html/mindmaps:

First we're going to install npm and clone the repository in /var/www/html/:


root@mindmaps:/var/www/html# apt install npm -y
	
root@mindmaps:/var/www/html# git clone https://github.com/drichard/mindmaps
Cloning into 'mindmaps'...
remote: Enumerating objects: 3640, done.
remote: Total 3640 (delta 0), reused 0 (delta 0), pack-reused 3640
Receiving objects: 100% (3640/3640), 2.24 MiB | 2.64 MiB/s, done.
Resolving deltas: 100% (2066/2066), done.

Once that's done, go in the repository directory to install the required dependencies:


root@mindmaps:/var/www/html# cd mindmaps/
root@mindmaps:/var/www/html/mindmaps# npm install
root@mindmaps:/var/www/html/mindmaps# npm run build

root@mindmaps:/var/www/html/mindmaps# ls dist/ -lash
total 44K
4.0K drwxr-xr-x 5 root root 4.0K Apr 15 08:35 .
4.0K drwxr-xr-x 9 root root 4.0K Apr 15 08:35 ..
8.0K -rw-r--r-- 1 root root 5.4K Apr 15 08:35 about.html
4.0K -rw-r--r-- 1 root root  770 Apr 15 08:35 cache.appcache
4.0K drwxr-xr-x 4 root root 4.0K Apr 15 08:35 css
4.0K drwxr-xr-x 2 root root 4.0K Apr 15 08:35 img
 12K -rw-r--r-- 1 root root 9.1K Apr 15 08:35 index.html
4.0K drwxr-xr-x 2 root root 4.0K Apr 15 08:35 js

root@mindmaps:/var/www/html/mindmaps# npm run start
npm WARN npm npm does not support Node.js v10.24.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/

> mindmaps@0.8.0 start /var/www/html/mindmaps
> http-server ./src -p 3000

Starting up http-server, serving ./src
Available on:
  http://127.0.0.1:3000
  http://10.0.0.171:3000
Hit CTRL-C to stop the server
	

Same as before, you can save and import your mindmaps:

Now let's CTRL+C to shutdown the npm server, and edit the nginx config:


^C
root@mindmaps:/var/www/html/mindmaps# vim /etc/nginx/sites-available/mindmaps.conf
	
upstream backend {
        server 127.0.0.1:3000;
}

server {
        listen 80;
        listen [::]:80;
        root /var/www/html/mymind;
        index index.html;
}

server {
        listen 8080;
        listen [::]:8080;
        location / {
                proxy_pass http://backend;
                proxy_http_version 1.1;
        }
}

:wq


Now let's get the systemd service file that will run npm for us because we don't want to manually launch a webserver in a production environnement:


root@mindmaps:/var/www/html/mindmaps# vim /etc/systemd/system/mindmap.service
	
[Unit]
Description=MindMaps npm service
After=network.target
After=systemd-user-sessions.service
After=network-online.target

[Service]
Type=simple
WorkingDirectory=/var/www/html/mindmaps
ExecStart=npm run start
Restart=always
RestartSec=10
KillMode=process

[Install]
WantedBy=multi-user.target

:wq

root@mindmaps:/var/www/html/mindmaps# systemctl daemon-reload
root@mindmaps:/var/www/html/mindmaps# systemctl enable --now mindmap
Created symlink /etc/systemd/system/multi-user.target.wants/mindmap.service → /etc/systemd/system/mindmap.service.
root@mindmaps:/var/www/html/mindmaps# systemctl status mindmap
● mindmap.service - MindMaps npm service
   Loaded: loaded (/etc/systemd/system/mindmap.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2021-04-15 08:49:27 UTC; 4s ago
 Main PID: 18872 (npm)
    Tasks: 19 (limit: 7372)
   Memory: 34.5M
   CGroup: /system.slice/mindmap.service
           ├─18872 npm
           ├─18883 sh -c http-server ./src -p 3000
           └─18884 node /var/www/html/mindmaps/node_modules/.bin/http-server ./src -p 3000

Apr 15 08:49:28 mindmaps npm[18872]: npm WARN npm can't make any promises that npm will work with this version.
Apr 15 08:49:28 mindmaps npm[18872]: npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
Apr 15 08:49:28 mindmaps npm[18872]: npm WARN npm You can find the latest version at https://nodejs.org/
Apr 15 08:49:28 mindmaps npm[18872]: > mindmaps@0.8.0 start /var/www/html/mindmaps
Apr 15 08:49:28 mindmaps npm[18872]: > http-server ./src -p 3000
Apr 15 08:49:29 mindmaps npm[18872]: Starting up http-server, serving ./src
Apr 15 08:49:29 mindmaps npm[18872]: Available on:
Apr 15 08:49:29 mindmaps npm[18872]:   http://127.0.0.1:3000
Apr 15 08:49:29 mindmaps npm[18872]:   http://10.0.0.171:3000
Apr 15 08:49:29 mindmaps npm[18872]: Hit CTRL-C to stop the server

Now that's done, we can reload our nginx server to see the config changes:


root@mindmaps:/var/www/html/mindmaps# nginx -s reload
	

And that's it! We managed to create a nginx reverse proxy to access our mindmaps npm http server via port 8080.

3




	


	


	

My Bunker

Some Address 67120,
Duttlenheim, France.

About Ech0

This cute theme was created to showcase your work in a simple way. Use it wisely.