# 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 127.0.0.1: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; ''""; }
# Redirect HTTP to HTTPS server { listen80; listen [::]:80; server_name vaultwarden.example.tld;
if ($host = vaultwarden.example.tld) { return301 https://$host$request_uri; } return404; }
server { # For older versions of nginx appened http2 to the listen line after ssl and remove `http2 on` listen443 ssl; listen [::]:443 ssl; http2 on; server_name vaultwarden.example.tld;