Aug 30, 2024 3 min read

KeeWeb: The Ultimate Guide to Self-Hosting

KeeWeb: The Ultimate Guide to Self-Hosting
Table of Contents

KeeWeb is a lightweight, open-source, self-hosted password manager designed for both personal and professional use. Its versatility lies in its ability to work seamlessly with KeePass files, customization for specific needs, and the control it provides over sensitive data. In this guide, we’ll walk through installing KeeWeb, configuring it with Nginx as a reverse proxy, enabling logging, setting up backups, updating the app, and leveraging its standout features.

Installing KeeWeb

πŸ“¦ Docker/Docker Compose Setup

Using Docker Compose is the easiest way to deploy KeeWeb. Here’s how to set it up:

  1. Create a new directory for your KeeWeb setup:

mkdir -p ~/keeweb && cd ~/keeweb

  1. Create a docker-compose.yml file:

version: '3.8'

services:

keeweb:

image: antelle/keeweb

container_name: keeweb

ports:

- "8080:80"

volumes:

- ./data:/data

restart: unless-stopped

  1. Deploy KeeWeb:

docker-compose up -d

  1. Verify the container is running:

docker ps | grep keeweb

Your KeeWeb instance will now be accessible at http://<your-server-ip>:8080.

πŸš€ Manual Installation

For those who prefer direct installation, follow these steps to install KeeWeb on a Linux server:

  1. Install dependencies (Node.js, npm, and Git):

sudo apt update

sudo apt install -y nodejs npm git

  1. Clone the KeeWeb repository:

git clone https://github.com/keeweb/keeweb.git

cd keeweb

  1. Build the application:

npm install

npm run build

  1. Serve KeeWeb using a static file server, such as Nginx or Apache:

npx http-server dist

You can now access KeeWeb by navigating to your server’s IP or hostname.

Configuring Nginx as a Reverse Proxy

🌐 Nginx Configuration

To route traffic to KeeWeb, create an Nginx server block:

  1. Edit or create a configuration file:

sudo nano /etc/nginx/sites-available/keeweb

  1. Add the following content:

server {

listen 80;

server_name keeweb.yourdomain.com;

location / {

proxy_pass http://127.0.0.1:8080;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

}

  1. Enable the configuration:

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

sudo nginx -t

sudo systemctl reload nginx

πŸ”’ SSL/TLS Setup

Secure your KeeWeb instance with Let’s Encrypt:

  1. Install Certbot:

sudo apt install -y certbot python3-certbot-nginx

  1. Obtain and configure an SSL certificate:

sudo certbot --nginx -d keeweb.yourdomain.com

  1. Automate certificate renewal:

sudo systemctl enable certbot.timer

Logging and Debugging KeeWeb

πŸ—ƒοΈ Enabling Debug Logs

Enable debug-level logging by setting the LOG_LEVEL environment variable in your Docker Compose file:


environment:

- LOG_LEVEL=debug

Restart the container to apply changes:


docker-compose restart keeweb

πŸ“„ Viewing Logs

To view logs for KeeWeb:

  • Docker logs:

docker logs keeweb

  • For a manual setup, check logs in the terminal where it’s running.

πŸ› οΈ Troubleshooting Common Issues

Look for common error messages in the logs, such as:

  • Missing files or permissions.

  • Incorrect proxy settings in Nginx.

For persistent problems, ensure all dependencies are installed correctly and access permissions are configured.

Backup and Restore

πŸ—‚οΈ File-Based Backups

KeeWeb primarily uses files for its configuration and data. Backup the data folder in Docker:


tar -cvzf keeweb-backup.tar.gz ~/keeweb/data

πŸ”„ Restoring Backups

To restore, extract the archive:


tar -xvzf keeweb-backup.tar.gz -C ~/keeweb/data

Then restart the Docker container:


docker-compose restart keeweb

πŸ“… Automated Backup Scripts

Automate backups with a cron job:


crontab -e

Add the following line:


0 2 * * * tar -cvzf ~/keeweb-backup-$(date +\%F).tar.gz ~/keeweb/data

Updating and Upgrading KeeWeb

⬆️ Updating Docker Images

Update the KeeWeb Docker image:


docker-compose pull

docker-compose up -d

πŸ› οΈ Manual Updates

For manually installed versions, pull the latest changes:


cd ~/keeweb

git pull

npm install

npm run build

πŸ” Checking for Updates

Visit KeeWeb’s GitHub repository to track releases:


https://github.com/keeweb/keeweb/releases

Leveraging KeeWeb’s Unique Features

πŸ”§ Enabling APIs

If you want to enable KeeWeb’s public API for automation, modify the configuration file:


{

"api": { "enabled": true }

}

🌟 Advanced Configurations

Customize KeeWeb by editing its configuration file (config.json):


{

"theme": "dark",

"autoSave": true

}

Reload KeeWeb to apply changes.

Wrapping Up

By following this guide, you’ve successfully deployed, customized, and secured KeeWeb on your own server. Whether you’re managing personal credentials or enterprise-level secrets, KeeWeb’s self-hosted model ensures flexibility, privacy, and control. Start implementing these steps today to unlock the full potential of KeeWeb for your workflow.

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.