栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

bitwarden

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

bitwarden

环境:ubuntu20.04LTS+Docker version 20.10.12

 

安装并部署bitwarden_rs

bitwarden_rs使用Docker进行安装,Docker安装过程不在此处赘述。

创建bitwarden_rs的运行目录
cd ~ && mkdir bitwarden && cd bitwarden
准备配置文件config.env

其他配置参数去bitwarden_rs wiki查看

cat >> config.env < 
服务描述文件 
cat >> docker-compose.yml < 
启动bitwarden_rs服务 
docker-compose up -d

运行后会自动拉去镜像和设置bitwarden_rs,耗时情况根据网络等因素拉取镜像快慢。

配置Let's Encrypt 生成证书并自动更新
sudo apt update

安装Nginx:ubuntu安装nginx后是自动启动的

sudo apt install nginx

查看nginx状态

sudo systemctl status nginx

 安装certbot及certbox的nginx插件

sudo apt install certbot & certbot-nginx
Let's Encrypt的两种认证方式

在Let‘s Encrypt签发证书时,它需要确定你要申请证书的域名的确是你拥有的,此时Let's Encrypt将向certbot客户端发起质询(challenge)以验证你对域名的拥有权,有两种方式:

  • 通过运行certbot的服务器与Let's Encrypt服务器通信,如果你配置域名指向该certbot所在的服务器,Let's Encrypt通过直接访问该域名的方式来验证(URL格式为:http://domain/.well-known/acme-challenge/)。这种方式通常用于单一域名的证书,需要certbot运行与域名所指向的服务器上。
  • 通过DNS,如果你拥有该域名,那么Let's Encrypt会让你在该域名下设置一个TXT记录,记录值设置成Let's Encrypt所要求的(在运行certbot时会提示),做到这一点则可以证明你的确拥有对该域名的拥有权。这种方式通常用于通配符证书,certbot无需运行在域名指向的服务器上。
创建证书 仅生成证书,而不自动更新nginx.conf配置文件
sudo certbot --nginx certonly

 邮件地址

服务条款

 是否共享邮件地址

 域名

certbot在生成证书后自动更新nginx.conf文件
sudo certbot --nginx 

域名

nginx配置

/etc/nginx/sites-available/default

server {
    if ($host = www.domain.com ) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
    listen 80 ;
    listen [::]:80 ;
    server_name /www.domain.com ;
    return 404; # managed by Certbot
}

server {
    listen 443 ssl http2;
    server_name /www.domain.com ;
    ssl_certificate /etc/letsencrypt/live/www.bitwarden.space/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/www.bitwarden.space/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    client_max_body_size 128M;

  location / {
    proxy_pass http://127.0.0.1:3001;
    proxy_http_version 1.1;
    proxy_cache_bypass $http_upgrade;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    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_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Port $server_port;
  }
  
  location /notifications/hub {
    proxy_pass http://127.0.0.1:3012;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
  }
  
  location /notifications/hub/negotiate {
    proxy_pass http://127.0.0.1:3001;
  }

  location /admin {
    # See: https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/
    #auth_basic "Private";
    #auth_basic_user_file /path/to/htpasswd_file;

    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://127.0.0.1:3001;
  }
}

重启nginx

sudo systemctl status nginx 

Enjoy it 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/685853.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号