How to Set Up NocoDB (with SSL)

Learn how to set up the NocoDB open source database as a spreadsheet application — Airtable alternative — in a secure manner.
Oct 21, 2022
7 min

Creating and managing information in a database doesn't have to be complex or time consuming. In fact, it can be as easy as using a spreadsheet. The article "When to Use a Database (as a Spreadsheet)" showcases why you should use a database as a spreadsheet. This guide covers how to set up a database as a spreadsheet using NocoDB.

What is NocoDB?

NocoDB is an open source no-code platform that turns any database into a smart spreadsheet. A no-code development platform allows programmers and non-programmers to create application software through graphical user interfaces and configuration instead of traditional programming methods. NocoDB describes itself as an Airtable alternative, which is a platform for building collaborative applications. Since NocoDB is open source, this means you can achieve the functionality of Airtable — by self-hosting an instance of NocoDB — for free!

Disclaimer: NocoDB uses an AGPLv3 license. This may affect your ability to use the application in your company (i.e Google AGPL Policy).

How to Set Up NocoDB

A full setup of NocoDB entails three steps.

  1. Setting up a relational database (optional).
  2. Setting up an instance of NocoDB on a server.
  3. Starting a project from scratch or by connecting to the relational database.

Note: You can use the NocoDB Documentation for more information.

Set up the Relational Database

A relational database provides data storage and query functionality. NocoDB currently supports multiple relational databases including SQLite, MySQL, MariaDB, PostgreSQL, Microsoft SQL Server, and AWS Aurora. This article will not focus on setting up a database due to the variety of methods available. In addition, NocoDB doesn’t require you to set up a database to use it. However, do note that connecting to an external database requires its connection credentials.

Set up the NocoDB Instance

The NocoDB web application (source on Github) provides the database as a spreadsheet functionality which includes the graphical interface used to interact with your data. This application must be run on a computer (server) that is able to access your database from a remote connection unless you are hosting the database in the same server as the NocoDB instance (localhost) or starting a project from scratch. In any case, you must set up a running instance of the application.

A host of methods to set up the NocoDB application is provided in the NocoDB Documentation (Installation). While you are able to set up this application on any computer, this guide assumes that you want your NocoDB instance to be available from anywhere (on your desktop or mobile device) and at all times. As a result, you should start with a physical or virtualized server that has access to the internet. In this guide, a virtualized server from Digital Ocean (Basic Droplet) will be used with the Ubuntu 22.04 LTS Operating System to install NocoDB using Docker.

Sign up to Digital Ocean with this referral link and get $200 in credit over 60 days: https://m.do.co/c/9d1115abd57c.

Step One: Install the NocoDB Prerequisites

A prerequisite to the NocoDB Docker Installation is Docker.

You can install Docker on Ubuntu 22.04 using the following article: How to Install and Use Docker on Ubuntu 22.04. If you set up your server by starting a droplet, then skip to step one of that guide. Step 2 and 3 are optional while step 4+ is NOT required to set up NocoDB.

Step Two: Install the NocoDB Instance (via Docker)

The steps to install NocoDB using a Docker command (for a number of databases) are found in the NocoDB Documentation (Install via Docker). Alternatively, use ONE of the command configurations below from the terminal of your server. In any case, a docker image will be pulled from NocoDB’s repository on Docker Hub.

Basic Installation

A basic installation of NocoDB sets up an instance using the default configuration. This will start your application on port 8080 (binding 8080 on the container to 8080 on the machine) using an SQLITE database (for the NocoDB application rather than any connected databases).

docker run -d --name nocodb \
-v "$(pwd)"/nocodb:/usr/app/data/ \
-p 8080:8080 \
nocodb/nocodb:latest

Production Installation

The NocoDB Documentation (Production Setup) provides a list of requirements to set up the application for production-usage; alongside a table of environment variables used to configure the application. Keep in mind that these environment variables refer to the data storage tool used to manage the NocoDB application, rather than any database you will be converting to a smart spreadsheet. Do note that “it is mandatory to configure the NC_DB environment variable for production usage”.

docker run -d --name nocodb \
-v "$(pwd)"/nocodb:/usr/app/data/ \
-p 8080:8080 \
-e NC_DB="INSERT APP DATABASE URL" \
nocodb/nocodb:latest

Private Installation

The above installations use default environment variables when unspecified. As a result, anyone who is able to access your NocoDB installation will be able to create an account on it (with the first being a Super Admin). In addition, telemetry will be enabled. If you prefer to only allow accounts to be created from the backend, set the NC_INVITE_ONLY_SIGNUP environment variable. In order to disable telemetry, set the NC_DISABLE_TELE environment variable.

docker run -d --name nocodb \
-v "$(pwd)"/nocodb:/usr/app/data/ \
-p 8080:8080 \
-e "NC_INVITE_ONLY_SIGNUP=true" \
-e "NC_DISABLE_TELE=true" \
nocodb/nocodb:latest

Secure Sockets Layer (SSL) Installation

In order to access your application from HTTPS, use the setup command from the "Set up NocoDB with SSL" section later in the article.

Step Three: Connect a Database to the NocoDB Instance

Once the docker command has been run, a NocoDB process will be started. You can ensure that this occurred by checking the process status of your containers using docker ps. You may have to wait a few minutes for the application to be ready for requests.

NocoDB docker ps

The image above shows the nocodb image with a container ID of d00ece744f52 running on port 8080 (tcp) on the server. This means that you can access the instance from port 8080 on the IPv4 address of your server. As an example, when the IPv4 address of the server is 159.223.148.220, entering 159.223.148.220:8080 into a browser will redirect you to the NocoDB signup page. If your server has port 8080 available to the internet, you will be able to access NocoDB from any device.

Want to use a domain? Create an A record in your DNS pointing your subdomain.domain.tls to the IPv4 address, then access the instance using subdomain.domain.tls:8080.

NocoDB Sign Up Page

Once a super user has been created, you will be able to sign in and create new projects. NocoDB provides you the ability to create a new project from scratch, which will store your data in the database that was specified during setup. Alternatively, connect to an external database by providing the necessary database credentials.

Connecting to a WordPress Database? Find your credentials in the wpconfig.php file. If you are using a managed WordPress instance, check the database manager in your dashboard (i.e phpMyAdmin on cPanel) or contact your hosting support team for the IP address of the server running the database. You may also have to enable remote connections using that same dashboard.

NocoDB Setup Project Button
Select the new project button.
NocoDB External Database Project Setup
The external credentials connection form.

You are able to use a database as a spreadsheet now.

NocoDB Project Dashboard
Congratulations!

Set up NocoDB with SSL (HTTPS)

Without a Secure Socket Layer (SSL), attackers are able to read and modify information that is transferred between your server and the server it’s sent to. This would allow them to perform problematic actions such as sniffing your NocoDB credentials (once entered), spoofing the instance, and reading data that is sent from your database. As a result, it’s recommended to add an SSL certificate to your server and interact with the application over the HTTPS protocol. Otherwise, configure a firewall to restrict the IPs your server can receive inbound connections from (in the next section).

Step One: Set Up a Domain

If you haven’t already, set up a domain that you can use to access your application from and point it to the IPv4 address of your server. As a reminder, you can do this by creating an A record in your DNS pointing your subdomain.domain.tls to the IPv4 address.

Step Two: Set Up a Reverse Proxy

NocoDB can be served over HTTPS through the use of a reverse proxy. This includes Apache, NGINX, Caddy, etc.

Caddy

Caddy is a reverse proxy built in Go that is built for simplicity. Install the stable release of Caddy from the Caddy Server Documentation (Install). You can use the command caddy version to confirm whether Caddy is available on your machine. The next step is to create a Caddyfile which adds SSL to your domain and forward port 8080 to port 443. You can do this with the following commands.

touch Caddyfile
nano Caddyfile

In the editor, add the following configuration.

subdomain.domain.tls

reverse_proxy localhost:8080

*Save using ctrl + X, Y, “Caddyfile”, Enter.

Restart the caddy server.

caddy stop
caddy start

If you haven’t already, be sure to start your NocoDB instance. Then, access your instance from the browser. It should indicate that you are accessing from HTTPS.

NocoDB SSL Domain
Congratulations!

NGINX

Nginx is a reverse proxy that can also be used as a reverse proxy, load balancer, mail proxy, and HTTP cache. As a result, it can be slightly more complicated to set up (with more than one way to do so). For a fresh NocoDB install, I recommend using the NGINX Proxy Automated ACME Companion to set up SSL with NGINX. This entails following step 1 and step 2 to run the nginx-proxy and acme-companion containers. Then, proxy the nocodb container by starting it with the following command.

If you have started your instance, stop it, then remove the image.

docker kill nocodb
docker rm nocodb

Start a proxied NocoDB container. You may have to wait a few minutes for the application to be ready for requests. Then, access your instance from the browser. It should indicate that you are accessing from HTTPS. The following configuration uses the environment variables present in the “Private Installation” section for more security.

docker run -d --name nocodb \
-v "$(pwd)"/nocodb:/usr/app/data/ \
-p 8080:8080 \
-e "NC_INVITE_ONLY_SIGNUP=true" \
-e "NC_DISABLE_TELE=true" \
-e "VIRTUAL_HOST=subdomain.yourdomain.tld" \
-e "LETSENCRYPT_HOST=subdomain.yourdomain.tld" \
nocodb/nocodb:latest
NocoDB SSL Domain
Congratulations!

Configure the Server Firewall

If you haven't already, you must configure the network firewall of your server so that you can only access the server (containing the NocoDB instance) from certain ports. In Digital Ocean, this is as simple as using the provided firewall feature. As an example, provide inbound access to port 22 and 443, then restrict access to port 8080 (with the reverse proxy configured). Alternatively, use the universal firewall (ufw) command-line tool to configure the firewall on Ubuntu.

For more information on securing a Digital Ocean Droplet, read Recommended Droplet Setup and watch Securing Your Droplet.

Need Help?

Want to save time from the efforts of a technical setup? SwitchUpCB Web Services provides a host of services, including the set up of a NocoDB project for you. Get started at https://switchupcb.com/services.

Read More

link