Simple Self-Hosted Hasura

With HTTPS, Docker, Digital Ocean, Google Domains

Image for post
Image for post
Photo by Jan Antonin Kolar on Unsplash

Hasura is an awesome tool to rapidly prototype a back end api. Hasura cloud is a newer product of theirs that allows you to pay for hosting a scalable Hasura instance. I recommend doing that instead of managing your own infrastructure, but I wanted to go through the process anyway and thought I’d share the steps I took.

There are a couple of assumptions in this article. I decided on using Digital Ocean, and I am using google domains for my domain names.

0. Setup/Sign up for digital ocean.

  1. Create a droplet on Digital Ocean by clicking the green create button in the upper left corner by your account.
Creating a droplet on digital ocean

2. Select market place and search for docker

3. You probably want to setup SSK authentication but for the purposes of this demo, let’s use a root password.

Image for post
Image for post
Setting a root password on digital ocean droplet.

4. Click create.

5. Go back to your droplets view, and find the droplet you just created. Click ‘more’ then add a domain

Image for post
Image for post
value then got Adding a domain on digital ocean droplet.

6. Follow the prompts and enter your domain, you’ll then get a list of records at the bottom of the page. Copy the A record value, then go to your domain provider.

7. Create a new A dns record that includes the sub domain you want for example and point it to the copied A record IP

This should setup your docker container, now you need to setup hasura to run on docker.

0. We’re going to be using this starter:

  1. ssh into your digital ocean droplet, by opening a new terminal window and typing ssh root@yourip (you can use once the name changes are propogated)
  2. clone the starter repo with git clone
  3. cd into the docker compose https manifest (this sets up https encryption by default)
cd graphql-engine/install-manifests/docker-compose-https/

4. Use a text editor to change the Caddyfile (either vim Caddyfile or nano Caddyfile ) to the following: {
reverse_proxy graphql-engine:8080

essentially this passes all traffic coming into our domain to a reverse proxy that goes to hasura.

5. Edit docker-compose.yaml with vim docker-compose.yaml

change the line with


remove the # to uncomment, and change myadminsecretkey to something for your hasura admin.

6. exit vim and run docker-compose up -d

You’re all set. You can now access your admin console here:

And your endpoint will be

(assuming DNS has finished propogating)

You can go to the console endpoint and just enter that secret key you set earlier.

Web/Mobile Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store