The API server for staticland! Static site hosting with SSL via Let's Encrypt
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
html
lib
nginx
tests
.gitignore
.travis.yml
LICENSE.md
README.md
example.config.js
index.js
package.json

README.md

staticland-api

A secure home for your static sites.

Features

  • One command to deploy a site.
  • Automatic SSL using Let's Encrypt.
  • Use any static site generator.
  • MIT licensed. Host it yourself. Use it how you want.

Install

Installing on Ubuntu 16.10

Install system dependencies

sudo apt-get update
sudo apt-get install git bc build-essential nginx
sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048

Install nvm & node

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash
. ~/.bashrc
nvm install v6

Install certbot

wget https://dl.eff.org/certbot-auto
chmod a+x ./certbot-auto
./certbot-auto

Install staticland-api

git clone https://github.com/staticland/staticland-api.git
cd staticland-api
npm i

staticland config

Copy the example config file and make changes if needed:

cp example.config.js config.js

set NODE_ENV to production

In the .bashrc file of the user that will run the staticland server add:

export NODE_ENV="production"

nginx config

You can use the nginx config files found in staticland/config.

Make sure to:

  • replace any references to api.static.land to the hostname you're using
  • change directory references if you place staticland or the sites in a different directory

Create cert for api server

cd ~
./certbot-auto certonly --standalone --agree-tos --redirect --duplicate --text --email hi@static.land -d api.static.land

restart nginx

sudo service nginx restart

install forever

npm i -g forever

set the STATICLAND_SECRET environment variable

export STATICLAND_SECRET=SomethingMoreSecretThanThis

start the staticland server

forever start index.js

renewing certificates

crontab -e
add a cron job for renewing site certificates
00 00 * * * node /home/ubuntu/staticland-api/bin/renew

Sites will get cert renewals based on the renewEvery value of the config.js file. The default value of 30 means certs will be renewed every 30 days.

add a con job for renewing the api server certificate
* 00 * * 1 /home/ubuntu/certbot-auto renew --standalone --pre-hook "service nginx stop" --post-hook "service nginx start" --quiet

Every Monday at midnight certbot will check to see if the certificate needs to be renewed.

License

MIT