准备
已按照章节 云服务器部署博客 部署
安装镜像 1 $ docker pull vaultwarden/server:latest
运行镜像 1 2 3 4 5 6 7 $ docker run -d -p 8000:80 \ -v /data/docker_volumes/vw-data/:/data/ \ -v /etc/localtime:/etc/localtime \ -e ADMIN_TOKEN=some_random_token_as_per_above_explanation \ --restart=always \ --name buubiu_vaultwarden \ vaultwarden/server:latest
配置域名证书 由于需要https,所以需要从厂商下载域名证书到服务器中。
创建相关目录
1 $ mkdir -p /data/docker_volumes/nginx/config/conf.d/pki/bitwarden.buubiu.com
把bitwarden.buubiu.pem、bitwarden.buubiu.key
拷贝到/data/docker_volumes/nginx/congfig/conf.d/pki/bitwarden.buubiu.com
中
新建nginx配置 在目录/data/docker_volumes/nginx/conf.d
创建配置:
注意:配置文件中不要把注释单独放在一行,一定要放在行尾
bitwarden.buubiu.conf 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 upstream vaultwarden-default { server 10.xx.xx.xx:8000 } upstream vaultwarden-ws { server 10.xx.xx.xx:3012; } server { listen 80; server_name bitwarden.buubiu.com; return 301 https://$host$request_uri ; } server { listen 443 ssl; server_name bitwarden.buubiu.com; ssl_certificate "/etc/nginx/conf.d/pki/bitwarden.buubiu.com/bitwarden.buubiu.com.pem" ; ssl_certificate_key "/etc/nginx/conf.d/pki/bitwarden.buubiu.com/bitwarden.buubiu.com.key" ; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; client_max_body_size 128M; location / { proxy_pass http://vaultwarden-default; 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 ; } location /notifications/hub { proxy_pass http://vaultwarden-ws; proxy_set_header Upgrade $http_upgrade ; proxy_set_header Connection "upgrade" ; proxy_set_header X-Real-IP $remote_addr ; } location /notifications/hub/negotiate { 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 ; proxy_pass http://vaultwarden-default; } location /admin { 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 ; proxy_pass http://vaultwarden-default; } }
重启nginx 1 $ docker restart buubiu_nginx
访问