Skip to content

Using an alternate base dir

Jeremy Lin edited this page Feb 19, 2020 · 9 revisions

Traditionally, Bitwarden is limited to residing at the root of a subdomain, e.g. https://bitwarden.example.com.

This limitation originates in the backend and web vault, which haven't been designed to accommodate alternate base dirs (see bitwarden/server#277). The mobile/desktop apps and browser extensions actually have no issues using a base URL with a path.

In bitwarden_rs, with the changes in PR#868, you can configure the backend server to work properly with an alternate base dir. With a bit more work, it's also possible to modify the web vault to work properly, resulting in a fully functional installation.

Configuring the backend server

Simply configure your domain URL to include the base dir. For example, suppose you want to access your installation at https://bitwarden.example.com/secret-dir.

  1. Stop bitwarden_rs.
  2. If you normally configure bitwarden_rs using the admin page, edit your config.json to look as follows:
    {
      "domain": "https://bitwarden.example.com/secret-dir",
      // ... other values ...
    }
  3. If you normally configure bitwarden_rs via environment variables, update your config files/scripts to set the DOMAIN environment variable to the base URL. For example:
    docker run -e DOMAIN="https://bitwarden.example.com/secret-dir" ...
  4. Restart bitwarden_rs.
  5. You should now be able to access the web vault (assuming it has been modified appropriately; see the next section) at https://bitwarden.example.com/secret-dir/ (note the trailing slash). For reasons not entirely clear, you may run into issues if you use https://bitwarden.example.com/secret-dir (without the trailing slash).
  6. Configure your apps or browser extensions to use https://bitwarden.example.com/secret-dir. If you add a trailing slash, the apps and extensions will automatically remove it before saving.

Modifying the web vault

The issue with the web vault is there's no simple way to configure it for a specific base URL. Instead, the code generally just assumes the web vault URL is given by window.location.origin, which always represents the root of the subdomain. This is true of both the upstream web vault and the patched version used in bitwarden_rs:

Here are some approaches you could take to modify the web vault to work at a different base dir.

The hard and clean way

Modify the upstream code and/or bitwarden_rs patches and rebuild the web vault. (Someone else can document this if they're interested.)

The quick and dirty way

  1. Enter a shell in the bitwarden_rs container: docker exec -it <container-name> /bin/sh
  2. Patch the web vault: sed -i "s|window\.location\.origin|window.location.origin+'/secret-dir'|g" /web-vault/app/main*.js (of course, replace /secret-dir with your actual base dir)

FAQs

  1. FAQs
  2. Audits
  3. Supporting upstream development

Troubleshooting

  1. Logging
  2. Bitwarden Android troubleshooting
  3. Bitwarden clients troubleshooting

Container Image Usage

  1. Which container image to use
  2. Starting a container
  3. Using Docker Compose
  4. Using Podman
  5. Updating the vaultwarden image

Reverse Proxy

  1. Proxy examples
  2. Using an alternate base dir (subdir/subpath)

HTTPS

  1. Enabling HTTPS
  2. Running a private vaultwarden instance with Let's Encrypt certs

Configuration

  1. Overview
  2. Enabling admin page
  3. SMTP configuration
  4. Disable registration of new users
  5. Disable invitations
  6. Enabling WebSocket notifications
  7. Enabling Mobile Client push notification
  8. Enabling SSO support using OpenId Connect
  9. Other configuration

Database

  1. Using the MariaDB (MySQL) Backend
  2. Using the PostgreSQL Backend
  3. Running without WAL enabled
  4. Migrating from MariaDB (MySQL) to SQLite

Security

  1. Hardening Guide
  2. Password hint display
  3. Enabling U2F and FIDO2 WebAuthn authentication
  4. Enabling YubiKey OTP authentication
  5. Fail2Ban Setup
  6. Fail2Ban + ModSecurity + Traefik + Docker

Performance

  1. Changing the API request size limit
  2. Changing the number of workers

Customization

  1. Translating the email templates
  2. Translating admin page
  3. Customize Vaultwarden CSS
  4. Using custom website icons
  5. Disabling or overriding the Vault interface hosting

Backup

  1. General (not docker)
  2. Backing up your vault

Development

  1. Building binary
  2. Building your own docker image
  3. Git hooks
  4. Differences from the upstream API implementation

Alternative deployments

  1. Pre-built binaries
  2. Creating a systemd service
  3. Third-party packages
  4. Deployment examples
  5. Disable the admin token

Other Information

  1. Importing data from Keepass or KeepassX
  2. Changing persistent data location
  3. Syncing users from LDAP
  4. Caddy 2.x with Cloudflare DNS
  5. Logrotate example

Clone this wiki locally