Self Hosting

Requirements

Hardware:

  1. A server / computer to run linux containers on. Docker Desktop with WSL also works, but isn't really recommended.

Software:

  1. Docker and docker compose installed on the server. You can use the Docker install script for linux, or Docker Desktop on Windows.

Other:

  1. Domain name, setup to pointed towards your server.
  2. HTTPS - required for cookies to work securely. You can use cloudflare for lets encrypt for example.

Preparing the server

Install software from the Requirements on the server.

Docker compose setup

Make a new folder in a known location.

Add two files with the names docker-compose.yml and .env. Paste their contents from below.

These two can also be found in the API repository

Variables that must be changed in .env:

  • PG_PASS is your primary postgres database password. Make it something secure like a random 32 character password.
  • OPENSHOCK_DOMAIN change this to your domain name. e.g. openshock.app
  • Email configuration. You need to decide between SMTP and MAILJET for your email sending service. Email server is currently required, this may change in the future.

You can change other variables in the docker-compose.yml. Check the API README for more information on the environment variables.

PS: the .env file is only actually used for variables in the docker-compose file itself and as the env_file for the api container. Feel free to change this.

Reverse proxy

By default the reverse proxy that comes with this example is traefik. Everything should be setup and should be available under https on port 443 on your domain if done correctly.

If you decide to have your own reverse proxy or just straight up use a different domain for short urls, you need to setup redirects.

  • /s/$ -> /#/public/proxy/shares/links/$
  • /c/$ -> /#/public/proxy/shares/code/$
  • /t/$ -> /#/public/proxy/token/$

There is a short hand letter, that redirects to the webui url, with this prefix added, and $ being a placeholder.

This setup also assumes that your frontend is for example under openshock.app. And API and Gateway are subdomains of the current domain name. If you want to have your frontend also be under a subdomain, you will need to edit the reverse proxy todo so. And set the frontend urls environment variables accordingly.

NGINX reverse proxy example with custom SSL

We can use this modified docker-compose.yml, difference here is, we removed traefik and added nginx. In addition we also need a ssl certificate, change the path to your needs, and create a nginx-site.conf file.

You will need to change the server names here!

Done

Congratulations, the backend and website should be working now. 🥳

You can now set the backend domain for the firmware to your api url via the domain serial command.

Last updated on

On this page