Skip to content

Latest commit

 

History

History
95 lines (67 loc) · 2.63 KB

SERVER.md

File metadata and controls

95 lines (67 loc) · 2.63 KB

Server Setup for ahap.info (onetech)

Here's how I setup a VPS to run ahap.info.

Basic Setup

I first setup a $5/month droplet on Digital Ocean with Ubuntu 22.04 and followed these instructions.

  1. Initial Server Setup
  2. Passwordless sudo
  3. Install Nginx
  4. Secure Nginx with Let's Encrypt
  5. Install Node.js with NVM
  6. Setup Node.js for Production

Site

Clone the onetech repo and build it:

git clone https://github.com/connorhsm/ahap.info
npm install
npm run build

Setup the server config:

server {
  root /var/www/ahap.info/onetech/public;
  index index.html;

  server_name ahap.info edge.ahap.info www.ahap.info;

  location / {
    try_files $uri $uri/ /index.html;
  }

  location ~* \.(ico|css|js|gif|jpe?g|png|json|svg)$ {
    # try the file directly
  }

  # ...
}

server {
  listen 80 default_server;
  listen [::]:80 default_server;
  server_name _;
  return 301 https://$host$request_uri;
}

I also enabled gzip on /etc/nginx/nginx.conf:

gzip on;

gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_min_length 256;
gzip_disable "MSIE [1-6].(?!.*SV1)";

Make sure to setup ahap.info domain to point to the droplet.

Process Script

Run this to install ImageMagick and Cairo for the node-canvas.

sudo apt-get install imagemagick libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev build-essential g++ libsox-fmt-mp3 sox

Then run it:

cd onetech
node process download

Cron

Setup cron to run the update script every so often, this will watch both Git repos and update the site when they change.

*/5 * * * * ONETECH_MOD_NAME="Another Hour Another Planet" ONETECH_PROCESS_GIT_URL="https://github.com/jasonrohrer/AnotherPlanetData" bash /var/www/ahap.info/onetech/updater/update.sh >> /var/www/ahap.info/onetech/updater/update.log 2>&1

That's it!