环境: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-nginxLet's Encrypt的两种认证方式在Let‘s Encrypt签发证书时,它需要确定你要申请证书的域名的确是你拥有的,此时Let's Encrypt将向certbot客户端发起质询(challenge)以验证你对域名的拥有权,有两种方式:
创建证书 仅生成证书,而不自动更新nginx.conf配置文件
- 通过运行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无需运行在域名指向的服务器上。
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 nginxEnjoy it
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)