How to Install HedgeDoc on Debian Latest

HedgeDoc is an open-source, real-time collaborative markdown editor. It enables users to create documents, presentations, and more, and to collaborate on them in real time with other users. In this tutorial, we will show you how to install HedgeDoc on Debian latest.

Prerequisites

Before we get started, make sure you have the following:

Step 1: Install Required Packages

First, update your system's package list and install the packages required for HedgeDoc:

sudo apt update
sudo apt install nginx mongodb markdown git build-essential

Next, install Node.js and Yarn by following these commands:

sudo apt-get install curl software-properties-common
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
curl -sL 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
sudo apt-get update && sudo apt-get install yarn

Step 2: Clone HedgeDoc from GitHub

Next, clone the HedgeDoc repository from GitHub into your server's /var/www directory:

cd /var/www
sudo git clone https://github.com/hedgedoc/hedgedoc.git
cd hedgedoc

Step 3: Install Required Dependencies

After you've cloned HedgeDoc, install the required dependencies with Yarn:

sudo yarn install

Step 4: Create a Config File

Create a new configuration file for HedgeDoc:

sudo cp ./config.sample.json ./config.json
sudo nano ./config.json

Update ./config.json to include your server's domain name, your SSL certificate paths, and your MongoDB connection string.

{
  "url": "https://your-domain.com",
  "port": 3000,
  "ssl": {
    "key": "/path/to/ssl/key",
    "cert": "/path/to/ssl/cert",
    "ca": "/path/to/ssl/ca"
  },
  "databaseUrl": "mongodb://localhost:27017/hedgedoc"
}

Step 5: Start the HedgeDoc Server

After you've created and updated ./config.json, start the HedgeDoc server:

sudo yarn start

Step 6: Configure nginx

To allow the HedgeDoc server to work alongside Nginx, create an Nginx configuration file:

sudo nano /etc/nginx/sites-available/your-domain.com

Update the configuration file with the following:

server {
  listen 80;
  listen [::]:80;

  server_name your-domain.com;

  location / {
    rewrite ^ https://$host$request_uri? permanent;
  }
}

server {
  listen 443 ssl;
  listen [::]:443 ssl;

  server_name your-domain.com;

  ssl_certificate /path/to/ssl/cert;
  ssl_certificate_key /path/to/ssl/key;

  location / {
    proxy_pass http://127.0.0.1:3000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_redirect     off;
  }
}

Next, enable the Nginx site and restart Nginx:

sudo ln -s /etc/nginx/sites-available/your-domain.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Access HedgeDoc

You can now access HedgeDoc at https://your-domain.com.

Conclusion

In this tutorial, we have covered the installation process for HedgeDoc on Debian latest. If you have any questions, feel free to leave a comment below.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!