Jinx

一只奶牛猫

Docker安装Bitwarden

发布于 # docker
services:
  vaultwarden:
    image: vaultwarden/server:latest
    container_name: vaultwarden
    restart: always
    environment:
      # DOMAIN: "https://vaultwarden.example.com"  # required when using a reverse proxy; your domain; vaultwarden needs to know it's https to work properly with attachments
      SIGNUPS_ALLOWED: "true" # Deactivate this with "false" after you have created your account so that no strangers can register
    volumes:
      - ./vw-data:/data # the path before the : can be changed
    ports:
      - 11001:80 # you can replace the 11001 with your preferred port

to create and run the container, run:

docker compose up -d && docker compose logs -f

to update and run the container, run:

docker compose pull && docker compose up -d && docker compose logs -f

Nginx

server {
  listen 80;
  # 改为你的网址
  server_name your.domain.name;
  # 重定向为 https
  return 301 https://$host$request_uri;
}

server {
  listen 443 ssl;
  http2 on;
  # 改为你的网址
  server_name your.domain.name;
  # 证书的公私钥
  ssl_certificate /etc/letsencrypt/live/your.domain.name/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/your.domain.name/privkey.pem;

  location / {
    # 改为容器的 PORT
    proxy_pass http://127.0.0.1:11001;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Upgrade $http_upgrade;
  }
}

注册完后然后再更改docker-compose.yaml

services:
  vaultwarden:
    image: vaultwarden/server:latest
    container_name: vaultwarden
    restart: always
    environment:
      DOMAIN: "https://vaultwarden.example.com"  # required when using a reverse proxy; your domain; vaultwarden needs to know it's https to work properly with attachments
      SIGNUPS_ALLOWED: "false" # Deactivate this with "false" after you have created your account so that no strangers can register
    volumes:
      - ./vw-data:/data # the path before the : can be changed
    ports:
      - 11001:80 # you can replace the 11001 with your preferred port