--- layout: storage description: "Storing user data with Blockstack" permalink: /:collection/:path.html --- # Configure a hub on Amazon EC2 {:.no_toc} This teaches you how to run a Gaia hub on Amazon EC2. Amazon EC2 is an affordable and convenient cloud computing provider. This example uses Amazon EC2 instance together with an [EBS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AmazonEBS.html) disk for file storage. * TOC {:toc}
This documentation is appropriate for advanced power users who are familiar with command line tools, ssh
, and basic editing configuration files.
If you are planning on running an open-membership hub or an application-specific hub, see the section on Hub Operation.
Select a VPC.
A default VPC is created with a free tier account. You can use this
default VPC. Or you can choose another VPC. If you choose another VPC,
ensure the Subnet
value is set to a subnet reachable by a public IP.
Set Protect against accidental termination.
If you terminate a Gaia instance, you lose all the data associated with it. Protection adds an extra step to terminating your Gaia instance.
Open the Advanced Details.
At this point, you are going to configure environment variables for your instance.
Paste the following into the Advanced Details.
{
"ignition": { "version": "2.2.0" },
"storage": {
"files": [{
"filesystem": "root",
"path": "/etc/environment",
"mode": 420,
"contents": {
"source": "data:application/octet-stream,API_KEY%3DKEYPHRASE%0ADOMAIN%3DNAME_OF_DOMAIN%0ASTAGING%3DSTAGING_VALUE"
}
}]
}
}
Replace the following values in the JSON.
Value | Description |
---|---|
<KEYPHRASE> |
A phrase to pass when using the hub admin. For example, hubba is a fun key phrase. |
<NAME_OF_DOMAIN> |
Your hub's domain name. For example, maryhub.ml is the domain name in this example. |
<STAGING_VALUE> |
Indicates what type of SSL to create, testing (`1`) or production (`0`). Set testing if you want to test without worrying about rate limiting. A testing cerificate is not secure. For this tutorial, use production (`0`). |
Check your Advanced Details they should look similar to the following:
{
"ignition": { "version": "2.2.0" },
"storage": {
"files": [{
"filesystem": "root",
"path": "/etc/environment",
"mode": 420,
"contents": {
"source": "data:application/octet-stream,API_KEY%3Dhubba%0ADOMAIN%3Dmaryhub.ml%0ASTAGING%3D0"
}
}]
}
}
Type | Protocol | Port Range | Source | Description |
---|---|---|---|---|
SSH | TCP | 22 | My IP | optional |
HTTP | TCP | 80 | Anywhere | optional |
HTTPS | TCP | 443 | Anywhere | optional |
If the response is | Do this... |
---|---|
You should see a message that your connection is not private. Everything is fine, continue to the next step, step 8. | |
|
Service | Description |
---|---|
certbot |
This service runs every 12 hours so you may not see it in the output. The service runs Let's Encrypt certbot client to support SSL. Certbot renews your certificates and reloads Nginx to pick up the changes. This service will run 2x per day checking if the certificate needs to be renewed. |
nginx |
Runs an Nginx proxy in front of the Gaia Hub. This service does things like rate-limiting, SSL termination, and redirects to HTTPS. Your nginx service relies on your hub's readURL to make requests. Changes to a hub's readURL must be reflected in the nginx service configuration in /gaia/nginx/conf.d/default.conf |
gaia-admin |
A simple administrative service that allows you to administer the Gaia hub. Use REST calls with this service to get and set hub configuration values. |
gaia-reader |
The Gaia read side-car services get file requests on URLs that start with
your Gaia hub's readURL . You can determine your Gaia hub's read URL by either
looking for the readURL key in your Gaia hub's config file. This value is or by looking for
the read_url_prefix field in the data returned by a HUB_URL/hub_info page on your
Gaia hub. |
gaia-hub |
The Gaia hub service. |
File or Directory | Description |
---|---|
/etc/systemd/system |
Contains systemd unit-files for managing your Gaia hub. |
/etc/environment |
Contains the DOMAIN and STAGING variables you entered when creating your EC2 instance.
|
/gaia/gaia.env |
Contains the environment variables used by the Gaia systemd unit-files.
|
/etc/systemd/system/reset-ssl-certs.service |
A service that removes all existing certificates and restarts all the Gaia hub services. Use this sparingly, since the Lets Encrypt service will throttle too many requests for certificates. |
/gaia/hub-config |
Configuration for the Gaia Hub service. |
/gaia/admin-config |
Configuration for the Gaia Hub admin service. |
/gaia/reader-config |
Configuration for the Gaia Hub reader service. |
/gaia/nginx/conf.d |
Configuration files for the Nginx service. |
/gaia/nginx/certbot/conf |
Lets Encrypt SSL certificates/configs. |
/gaia/scripts |
Scripts run by the systemd services on startup. |