# $NetBSD: httpd-vaultwarden.conf,v 1.1 2022/08/17 15:44:16 hauke Exp $

# Apache 2.4 configuration snippet for running vaultwarden behind a
# reverse proxy.
#
# The location does not have a trailing slash, since the Bitwarden
# browser client will strip it. The corresponding vaultwarden.env
# DOMAIN setting is supposed to hold the server's hostname, but not
# the path.

<Location "/bitwarden">

    # WebSocket notifications
    RewriteEngine On
    RewriteCond %{HTTP:Upgrade} websocket [NC]
    RewriteCond %{HTTP:Connection} upgrade [NC]
    RewriteRule ^/?(.*) "ws://localhost:3012/$1" [P,L]

    ProxyPass "http://localhost:8000"
    ProxyPreserveHost On
    RequestHeader set X-Real-IP %{REMOTE_ADDR}s
</Location>
