Skip to content

Installation Guide

David Alexandru Ilie edited this page Oct 21, 2021 · 14 revisions

Throughout this guide, you'll learn how to install the app using either:

This guide does assume you are at least somewhat familiar with Linux systems, and already have everything running for the option you picked to install with.

Installing with docker-compose

Before we continue, the steps we are doing here can be done automatically from the ansible playbook below.

Prerequisites

  • You need to have docker and docker-compose installed and working
  • You need to have ports 80, 4000, 5000, 27017 available for the different services to use them
  • You need to have a good amount of storage to store the files

Configuring the docker-compose yaml file

First, you need to clone the respository to your server (not your compuer)

git clone https://github.com/davidilie/sharex-upload-server.git && cd sharex-upload-server

With that done you need to navigate to the docker-compose deployment category.

cd deployment/docker-compose

With that now, you need to open the .yml file with your editor of choice.

nano docker-compose.yml

As I can't know your precise configuration, I will just point out the variables you can change in both the frontend and backend

Backend

  • MONGO_URI - The URI of your MongoDB instance (default: mongodb)
  • FRONTEND_URL - The URL of your frontend instance (default: http://localhost)
  • API_URL - The URL that the server will be running on (default http://localhost)
  • ACCESS_TOKEN_SECRET - IT IS MANDATORY that you change this to something random, if you don't change it, a malicious attacker can generate authentication tokens using the default token (default: ioasbdiuabsdiuasduibasdo)

Frontend

  • APP_URL - The URL of your frontend instance (default: http://localhost)
  • API_URL - The URL that the server will be running on (default http://localhost)
  • SERVER_API_URL - The URL that your frontend will locally make requests to (default http://server:4000)

Other things that you can configure

  • You can modify the docker-compose.yaml file to use a different path for the MongoDB database or the storage folder.
  • You can modify the nginx configuration by modifying the file ./nginx.conf

Deploying the app

Once you're sure that you configured everything to your needs, you can run this command to start up the services.

docker-compose up -d

This will pull the docker images and configure them according to your configuration.

The entire app should now be setup!

Installing with Ansible

We're going to be using Ansible, a basic automation tool which installs everything we do the docker-compose option automatically.

Prerequisites

  • You need to have ports 80, 4000, 5000, 27017 available for the different services to use them
  • You need to have a good amount of storage to store the files

Don't let this worry you, if you don't understand, move on and come back to this later.

Installing ansible

sudo apt-get install -y ansible

It's good to restart your SSH connection now so that ansible and ansible-galaxy will be available.

Downloading the repository and navigating to the correct folder

git clone https://github.com/davidilie/sharex-upload-server.git && cd sharex-upload-server

With that done you need to navigate to the docker-compose deployment category.

cd deployment/ansible

Install requirements: ansible-galaxy collection install -r requirements.yml.

Configuring the ansible playbook

Once in the directory, you should see two files:

  • example.config.yml - Stores the configuration for your install
  • example.inventory.ini - Keeps the IP address of your server

You need to make your own copy of these two files so we can modify them:

cp example.config.yml config.yml
cp example.inventory.ini inventory.ini

Let's first modify the inventory.yml file to point to the IP address of your server, or enable the second flag if you're installing on the same machine you're running ansible:

# make sure to change the ansible_user flag to your own username
[sharex-upload-server]
192.168.1.214 ansible_user=david

# Comment out the previous line and uncomment this to run inside your server.
# 127.0.0.1 ansible_connection=local ansible_user=david

Finally, you need to modify the config.yml file to your needs and use the comments on top as reference:

# Location where configuration files will be stored.
config_dir: "~"

# Make sure this points to your PRODUCTION url!
frontend_url: "http://localhost"
backend_url: "http://localhost"

# Authorization - Make sure you change this!
access_token_secret: "iansdibasdibasdibasidu"

# Path for where the uploads are stored
upload_dir: "~/uploads"

If you have another disk where you would like to store your uploaded files (such as an HDD, mounted network share, etc). You can modify the upload_dir path to point to your location where you would like to store your data.

Running the playbook

This is (in my opinion), the most satisfying part of this process as you see everything installing automatically. In order to witness such experience, run this command:

ansible-playbook main.yml --become --ask-become-pass

This installs everything required and also starts it too. After its done, the entire app should now be setup!

Default login credentials

You can try visiting the site in your browser, if everything is set up correctly you should be presented with a login screen, you can log in using the credentials below as an admin user.


Now that the media server should've been setup you can check out the setting up ShareX guide to learn how to setup ShareX so that it can properly talk to the media server.