Security

Learning cybersecurity - Hands-on activity: secure deployment of the Bitw password manager

Deploying Vaultwarden in a Docker container, then publishing it over HTTPS with a self-signed certificate and an nginx reverse proxy configuration file.

· 1 min read · level: intermediate

1. Deploying the container

docker pull vaultwarden/server:latest
docker run -d --name vaultwarden -v /vw-data/:/data/ --restart unless-stopped -p 8443:80 vaultwarden/server:latest

2. Access over self-signed HTTPS

Generating the self-signed certificate:

  • Use OpenSSL to generate a private key and a self-signed certificate.

Command:

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/selfsigned.key -out /etc/ssl/selfsigned.crt

Creating the configuration in nginx:

nano /etc/nginx/sites-available/vaultwarden
server {
    listen 443 ssl;
    server_name SAISIR_VOTRE_IP_OU_DOMAINE;

    ssl_certificate /etc/ssl/selfsigned.crt;
    ssl_certificate_key /etc/ssl/selfsigned.key;
    location / {
        proxy_pass http://localhost:8443;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Creating the symbolic link to enable the site:

ln -s /etc/nginx/sites-available/vaultwarden /etc/nginx/sites-enabled/vaultwarden

Restarting the nginx service:

systemctl restart nginx

That is all: you now simply need to open your browser at https://