Introduction
Vaultwarden is a self-hosted alternative to popular password managers like LastPass and 1Password. It runs as a Docker container, making it easy to set up and manage. Let's Encrypt SSL certificates secure the communication between the client and the server, adding an extra layer of security. In this article, we will cover how to manage Vaultwarden access and obtain Let's Encrypt SSL certificates using Caddy.
Prerequisites
Before we begin, ensure you have the following prerequisites in place:
- Docker installed on your local machine
- Basic knowledge of Docker and Docker Compose
- A domain name registered and configured with a DNS provider
Installing Caddy
Caddy is a powerful, enterprise-ready, open-source web server with automatic HTTPS written in Go. To install Caddy, follow the steps below:
- Download the latest release from https://caddyserver.com/docs/install
- Extract the contents of the downloaded archive
- Move the Caddy executable to a system directory (e.g., /usr/local/bin)
Configuring Caddyfile
Create a new file named 'Caddyfile' in the same directory as the Caddy executable. Add the following content:
# Caddyfile for managing Vaultwarden access and Let's Encrypt SSL certificates
vaultwarden:
reverse_proxy /vaultwarden /var/run/docker.sock:2376/vaultwarden
tls {
key /etc/ssl/private/vaultwarden.key
cert /etc/ssl/certs/vaultwarden.cert
}
web:
reverse_proxy / /var/www/html
tls {
key /etc/ssl/private/example.com.key
cert /etc/ssl/certs/example.com.cert
}
Obtaining Let's Encrypt Certificates
To obtain Let's Encrypt certificates for your domain, update the 'web' section in the Caddyfile with your domain name:
web:
reverse_proxy / /var/www/html
tls {
key /etc/ssl/private/example.com.key
cert /etc/ssl/certs/example.com.cert
automobile
}
Save the file and run the following command:
caddy run --config Caddyfile
Caddy will automatically obtain the Let's Encrypt certificate for your domain.
Configuring Vaultwarden
To configure Vaultwarden, create a new file named 'docker-compose.yml' in the same directory as the Caddy executable:
version: '3.8'
services:
vaultwarden:
image: haugene/vaultwarden:latest
container_name: vaultwarden
ports:
- "8080:8080"
- "8443:8443" volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
"./data:/data"
Save the file and run the following command:
docker-compose up -d
Vaultwarden is now accessible at https://localhost:8443.
Accessing Vaultwarden
Access Vaultwarden using your preferred password manager client, such as KeePass or Bitwarden. Configure the client to use the Vaultwarden server at https://localhost:8443.
Summary
In this article, we covered how to manage Vaultwarden access and obtain Let's Encrypt SSL certificates using Caddy. We installed Caddy, configured the Caddyfile, obtained Let's Encrypt certificates, and set up Vaultwarden. By following these steps, you can secure your self-hosted password manager with SSL certificates.