Jul 11, 2024 3 min read

EtherCalc: Self-Hosting Made Simple

EtherCalc: Self-Hosting Made Simple
Table of Contents

EtherCalc is an open-source, web-based spreadsheet application that enables real-time collaboration. It's a lightweight and versatile alternative to proprietary solutions, making it ideal for self-hosting to retain full control over your data. In this guide, we'll cover how to install EtherCalc, configure it securely, set up logging and backups, keep it updated, and optimize its unique features for advanced use.

Installing EtherCalc

πŸ“¦ Docker/Docker Compose Setup

Using Docker is one of the easiest ways to deploy EtherCalc. Below is a docker-compose.yml file to get started:


version: '3.8'

services:

ethercalc:

image: audreyt/ethercalc

container_name: ethercalc

ports:

- "8000:8000"

volumes:

- ./data:/data

environment:

- NODE_ENV=production

Save this file in your project directory and run the following commands to deploy EtherCalc:


docker-compose up -d

## Check the status of the container

docker-compose ps

Visit http://<your_server_ip>:8000 to access EtherCalc.

πŸš€ Manual Installation

To install EtherCalc directly on a Linux server, follow these steps:


## Update the package index

sudo apt update

## Install Node.js and npm

sudo apt install -y nodejs npm

## Install EtherCalc globally

sudo npm install -g ethercalc

## Start EtherCalc

ethercalc

By default, EtherCalc will run on port 8000. Use http://<your_server_ip>:8000 to check if it's running.

Configuring Nginx as a Reverse Proxy

🌐 Nginx Configuration

To make EtherCalc accessible via a custom domain, configure Nginx as a reverse proxy. Create a new server block file, e.g., /etc/nginx/sites-available/ethercalc:


server {

listen 80;

server_name yourdomain.com;

location / {

proxy_pass http://localhost:8000;

proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection 'upgrade';

proxy_set_header Host $host;

proxy_cache_bypass $http_upgrade;

}

}

Enable the configuration and restart Nginx:


## Link the configuration file

sudo ln -s /etc/nginx/sites-available/ethercalc /etc/nginx/sites-enabled/

## Test the configuration

sudo nginx -t

## Reload Nginx

sudo systemctl reload nginx

πŸ”’ SSL/TLS Setup

Secure your EtherCalc instance with Let's Encrypt:


## Install Certbot

sudo apt install -y certbot python3-certbot-nginx

## Obtain an SSL certificate

sudo certbot --nginx -d yourdomain.com

## Verify auto-renewal

sudo certbot renew --dry-run

Your EtherCalc instance is now accessible at https://yourdomain.com.

Logging and Debugging EtherCalc

πŸ—ƒοΈ Enabling Debug Logs

Debug logging helps troubleshoot issues. Modify the startup command to enable verbose logs:


ETHERCALC_DEBUG=true ethercalc

For Docker users, update the docker-compose.yml file:


environment:

- NODE_ENV=production

- DEBUG=ethercalc:*

Restart the container:


docker-compose down && docker-compose up -d

πŸ“„ Viewing Logs

Use the following commands to view logs:


## For Docker

docker logs ethercalc

## For manual installations

journalctl -u ethercalc

πŸ› οΈ Troubleshooting Common Issues

Check for the following common issues:

  • Port conflicts: Ensure no other application is using port 8000.

  • Nginx misconfiguration: Verify the proxy settings in /etc/nginx/sites-available/ethercalc.

πŸ“€ Exporting Logs

Forward logs to an external system like the ELK Stack for advanced analysis:


## Example using Filebeat

sudo apt install -y filebeat

sudo filebeat setup

sudo systemctl start filebeat

Configure Filebeat to read EtherCalc logs and send them to your ELK instance.

Backup and Restore

πŸ—‚οΈ File-Based Backups

Back up EtherCalc's data directory (for Docker setups, ./data):


## Compress the data directory

tar -czvf ethercalc-backup.tar.gz ./data

Restore the backup:


## Extract the backup

tar -xzvf ethercalc-backup.tar.gz -C ./data

πŸ”„ Database Backups

If using an external database (e.g., Redis), back up the database as well:


## Dump Redis data

redis-cli save

## Copy the dump file

cp /var/lib/redis/dump.rdb ./backup/

Restore the database:


## Copy the dump file back

cp ./backup/dump.rdb /var/lib/redis/

## Restart Redis

sudo systemctl restart redis

πŸ“… Automated Backup Scripts

Create a cron job to automate backups:


## Edit the crontab file

crontab -e

## Add the following line to back up every night at 2 AM

0 2 * * * tar -czvf /path/to/backup/ethercalc-$(date +\%F).tar.gz /path/to/data

Updating and Upgrading EtherCalc

⬆️ Updating Docker Images

For Docker deployments, update to the latest EtherCalc image:


## Pull the latest image

docker-compose pull

## Redeploy the container

docker-compose down && docker-compose up -d

πŸ› οΈ Manual Updates

For manual installations, update EtherCalc via npm:


## Update the npm package

sudo npm update -g ethercalc

πŸ” Checking for Updates

Keep an eye on the official EtherCalc GitHub repository for announcements about new releases or features.

Leveraging EtherCalc’s Unique Features

πŸ”§ Enabling APIs

EtherCalc supports APIs for programmatic interaction. To enable the API, ensure your server is running, then access the /_api endpoint:


## Example: Create a new sheet using the API

curl -X POST http://localhost:8000/_/new

🌟 Advanced Configurations

Customize EtherCalc by editing its environment variables. For example, to change the default port:


## Manual installation

ETHERCALC_PORT=8080 ethercalc

## Docker setup

environment:

- PORT=8080

Restart your application to apply the changes.

Wrapping Up

In this guide, we covered the entire lifecycle of deploying, configuring, and managing EtherCalc, from installation to troubleshooting and updates. By self-hosting EtherCalc, you gain full control over your collaborative spreadsheet app while keeping your data private and secure. Start implementing these steps today and unlock the full potential of EtherCalc to meet your team's collaboration needs!

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Selfhosted Ninja.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.