I’ve had this question asked a few times as well. How do you run a Gaia hub that stores data to the local filesystem, and not to a cloud? To do so, you’ll need to do the following.
WARNINGS
This should be taken as a draft of documentation. Please report bugs in this forum thread.
Step 1: Install Gaia and Gaia Reader
You can install the Gaia hub from source using the documentation in its README.
You will want to additionally install the “Gaia reader.” This is a program that is specifically designed to allow you to read data stored to the local filesystem while preserving the MIME type. You can get it up and running by following the instructions on its README.
Step 2: Configure Gaia
You will want to use the disk
driver. Here is a sample config file for doing so. This config will store the data under /tmp/gaia-disk
, will accept writes on port 4000, and will advertise its read endpoint (readURL
) as https://my-gaia-hub.com/
. Keep this value in mind, since it will influence how we will configure the Gaia reader.
{
"servername": "localhost",
"port": 4000,
"driver": "disk",
"readURL": "https://my-gaia-hub.com/",
"proofsConfig": {
"proofsRequired" : 0
},
"diskSettings": {
"storageRootDirectory": "/tmp/gaia-disk"
},
"pageSize": 20,
"argsTransport": {
"level": "debug",
"handleExceptions": true,
"stringify": true,
"timestamp": true,
"colorize": false,
"json": true
}
}
The Gaia reader’s config will look like this:
{
"port": 5000,
"diskSettings": {
"storageRootDirectory": "/tmp/gaia-disk"
}
}
Note that the port
is 5000 here. Also, notice that the diskSettings.storageRootDirectory
matches the same value in the hub’s configuration file (/tmp/gaia-disk
). This will need to be the case if you make changes to where the data is stored.
Step 3: Configure an Nginx proxy
The Gaia hub reader will handle HTTP GET requests, and return file data stored to /tmp/gaia-disk
with the appropriate MIME type. However, the Gaia reader is just a node.js server, and it doesn’t speak HTTPS. We’ll need to set up an Nginx proxy to handle that.
To do so, you’ll want to install Nginx, and make Nginx handle reads through the Gaia reader. Nginx can’t just serve data out of /tmp/gaia-disk
on its own, since it doesn’t know the MIME type to serve. Instead, we’ll configure Nginx to use the Gaia reader as a back-end as follows:
server {
# NOTE: SSL configuration details are omitted
server_name gaia_proxy;
listen 443;
listen [::]:443;
root /var/www/html;
index index.html;
# forward requests for data to the reader
location ~ ^/hub/.+ {
proxy_pass http://localhost:5000;
}
# forward requests for / and /hub_info to the Gaia hub
location /hub_info {
proxy_pass http://localhost:4000;
}
location / {
proxy_pass http://localhost:4000;
}
}
The proxy_pass
directives send data to and from the Gaia hub and Gaia reader.
Putting it all Together
The Nginx server will serve GET requests for https://my-gaia-hub.com/hub/$FILEPATH
, which it will pass to the Gaia reader on http://localhost:5000
. The Gaia reader will load data from /tmp/gaia-disk/$FILEPATH
and reply to the GET request with the appropriate MIME type. Remote clients will write to the Gaia hub by POST-ing writes to /
, which will be sent to the Gaia hub. Remote clients will connect to the Gaia hub by GET-ing /hub_info
, which will be forwarded to the Gaia hub as well.