From ceb19235d563565f0e979cf493855c569957f832 Mon Sep 17 00:00:00 2001 From: Amritanshu Date: Fri, 16 Feb 2024 20:19:27 +0530 Subject: [PATCH] Updated bitwarden to v1.30 it no longer needs to redirect to port 3012 for websockets --- bitwarden/files/nginx.conf.j2 | 38 +++++++++++++++-------- bitwarden/roles/bitwarden/tasks/main.yaml | 1 - 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/bitwarden/files/nginx.conf.j2 b/bitwarden/files/nginx.conf.j2 index f9928b6..f56f10e 100644 --- a/bitwarden/files/nginx.conf.j2 +++ b/bitwarden/files/nginx.conf.j2 @@ -1,30 +1,42 @@ +# The `upstream` directives ensure that you have a http/1.1 connection +# This enables the keepalive option and better performance +# +# Define the server IP and ports here. +upstream vaultwarden-default { + zone vaultwarden-default 64k; + server localhost:8080; + keepalive 2; +} + +# Needed to support websocket connections +# See: https://nginx.org/en/docs/http/websocket.html +# Instead of "close" as stated in the above link we send an empty value. +# Else all keepalive connections will not work. +map $http_upgrade $connection_upgrade { + default upgrade; + '' ""; +} + server { listen 80; server_name {{ http_host }}; # Allow large attachments - client_max_body_size 128M; + client_max_body_size 525M; location / { + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; - proxy_pass http://localhost:8080; 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 /notifications/hub { - - proxy_pass http://localhost:3012; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - } - - location /notifications/hub/negotiate { - - proxy_pass http://localhost:8080; - } } diff --git a/bitwarden/roles/bitwarden/tasks/main.yaml b/bitwarden/roles/bitwarden/tasks/main.yaml index 4534358..5fd9199 100644 --- a/bitwarden/roles/bitwarden/tasks/main.yaml +++ b/bitwarden/roles/bitwarden/tasks/main.yaml @@ -25,6 +25,5 @@ - "postgres:db" published_ports: - 127.0.0.1:8080:80 - - 127.0.0.1:3012:3012 volumes: - "/var/lib/{{ host_directory }}/data:/data/"