Andrew SB
How To Use the Horizon One-Click Install Image
How To Use the Horizon One-Click Install Image
We hope you find this tutorial helpful. In addition to guides like this one, we provide simple cloud infrastructure for developers. Learn more →

How To Use the Horizon One-Click Install Image

Posted May 17, 2016 15.2k views One-Click Install Apps Node.js NoSQL


DigitalOcean's Horizon One-Click Application provides a convenient way to get started with Horizon and get your RethinkDB-powered projects up and running. With Horizon, RethinkDB, and Node.js all pre-installed, the One-Click is a great base for building your application. This tutorial will give you all the details you need to get your project off the ground.

Horizon is an open-source developer platform for building realtime applications. It includes a middleware server that connects to RethinkDB and exposes an API as well as a JavaScript client library which allows front-end developers to store documents and subscribe to streaming data. Employing RethinkDB and websockets, Horizon seeks to make it simple for developers to stand up modern, realtime applications without the need for writing backend code. For a full rundown, see their documentation at

In addition to what comes on a standard Ubuntu 14.04 Droplet, the Horizon One-Click Application includes the following components:

  • Horizon
  • RethinkDB
  • Node.js
  • Nginx

For convenience, the git package is installed on the image.

Creating Your Horizon Droplet

You can launch a new Horizon instance by selecting Horizon with RethinkDB on 14.04 from the Applications menu during Droplet creation:

Control panel

Once you have created the Droplet, connect to it via the web-based console in the DigitalOcean control panel or SSH:

ssh root@your.ip.address

Accessing RethinkDB

The Horizon One-Click Application comes with RethinkDB preconfigured. It's web-based admin panel sits behind an Nginx reverse proxy. This allows it to be password protected. The password is randomly-generated on first boot, and can be found in the message of the day (MOTD) that will appear whenever you log into the server via SSH. The MOTD should look something like this:

Thank you for using DigitalOcean's Horizon/RethinkDB Application.

Your RethinkDB dashboard can be accessed at

Your RethinkDB login credentials are:
Username: admin
Password: 51PwBG3saQ


To remove this information from the MOTD, run:

  • sudo rm -f /etc/motd.tail

You can change the password for the admin user by running:

  • sudo htpasswd -cb /etc/rethinkdb/.htpasswd admin my-new-password

Getting Started with Horizon

Horizon currently includes three main components:

  • A middleware server that connects to RethinkDB and serves the client API and WebSocket endpoint
  • A client library for use in your applications
  • A command line tool, hz

Creating Your Project

The hz can be used to generate a project template and serve your Horizon app. To produce the scaffolding for your first app, run:

  • hz init myapp

This produces a sample configuration file and project structure in the myapp directory. Taking a closer look, you'll find:

cd myapp
tree -aF
├── dist/
│   └── index.html
├── .hz/
│   └── config.toml
└── src/

3 directories, 2 files

The .hz/config.toml is your project's configuration file. For more details on it's content, see Horizon's documentation.

dist/index.html contains a sample app that simply connects to the Horizon server to verify that it is working.

<!doctype html>
    <meta charset="UTF-8">
    <script src="/horizon/horizon.js"></script>
      var horizon = Horizon();
      horizon.onReady(function() {
        document.querySelector('h1').innerHTML = 'myapp works!'

Serving Your Project

The quickest way to serve your Horizon project is by using the command hz serve --dev --bind all. Now, when you browse to http://droplet.ip.add:8181 you should see a message indicating that the app successfully connected to the Horizon server:

It works!

To better understand what this command does, let's break it down. By default, hz serve will only serve the application on localhost. In order to make it publicly available, we use the --bind all flag. The --dev flag combines a number of separate settings into one flag in order to provide a convenient way to serve your application while developing. It is the equivalent to using the following flags:

Flag Purpose
--secure no Not served with encryption, no need to provide SSL cert
--start-rethinkdb yes Starts a separate RethinkDB instance with a datastore in rethinkdb_data/
--auto-create-tables yes Creates tables in RethinkDB automatically
--auto-create-indexes yes Creates indexes in RethinkDB automatically
--serve-static ./dist Serves static content from dist/

These defaults get you up and running quickly, but they should not be used in a production environment.

To connect to the already running RethinkDB instance rather than the development instance, you can use:

  • hz serve --dev --bind all --start-rethinkdb no --connect localhost

Keeping Up-To-Date

Horizon is installed system-wide via Node Package Manager, npm. In order to update it to the most recent version, just run:

  • sudo npm update -g horizon

Node.js is installed using the NodeSource Apt repository for the 6.x "Current" series, while RethinkDB is installed from the project's own Apt repository. So both components will receive updates as you update the rest of your system as you normally would:

  • sudo apt-get update
  • sudo apt-get upgrade

Next Steps

Creative Commons License