Move selfhosted bitwarden to subfolder

I have a self hosted bitwarden docker instance on a ubuntu 20.04 vm. I want to move it from being accessed from https:// to https:///bitwarden. I can’t for the life of me figure out how to accomplish this. Any help would be greatly appreciated.

Hello @John_Morren,
do you mean from http://example.com to http://example.com/bitwarden ?

Did you try to change globalSettings__baseServiceUri__vault?

I swear I tried that but can trst it again to be sure. You are referring to the setting in env/global.override.env correct?

@Pulsar - ok. I tried that. It is not working. Perhaps I did that wrong. Here is that configuration file.

sudo cat bwdata/env/global.override.env
globalSettings__baseServiceUri__vault=https://example.com/bitwarden
globalSettings__baseServiceUri__api=https://example.com/api
globalSettings__baseServiceUri__identity=https://example.com/identity
globalSettings__baseServiceUri__admin=https://example.com/admin
globalSettings__baseServiceUri__notifications=https://example.com/notifications
globalSettings__sqlServer__connectionString=“Data Source=tcp:mssql,1433;Initial Catalog=vault;Persist Security Info=False;User ID=sa;Password=redacted;MultipleActiveResultSets=False;Connect Timeout=30;Encrypt=True;TrustServerCertificate=True”
globalSettings__identityServer__certificatePassword=redacted
globalSettings__attachment__baseDirectory=/etc/bitwarden/core/attachments
globalSettings__attachment__baseUrl=https://example.com/attachments
globalSettings__dataProtection__directory=/etc/bitwarden/core/aspnet-dataprotection
globalSettings__logDirectory=/etc/bitwarden/logs
globalSettings__licenseDirectory=/etc/bitwarden/core/licenses
globalSettings__internalIdentityKey=redacted
globalSettings__duo__aKey=redacted
globalSettings__installation__id=redacted
globalSettings__installation__key=redacted
globalSettings__yubico__clientId=REPLACE
globalSettings__yubico__key=REPLACE
[email protected]
globalSettings__mail__smtp__host=REPLACE
globalSettings__mail__smtp__port=587
globalSettings__mail__smtp__ssl=false
globalSettings__mail__smtp__username=REPLACE
globalSettings__mail__smtp__password=REPLACE
globalSettings__disableUserRegistration=false
globalSettings__hibpApiKey=REPLACE
adminSettings__admins=

At the moment, example.com comes up with bitwarden, but /bitwarden doesn’t. I restarted the docker instance, did I miss something?

I have the same problem. I tried changing it in the .yml and .env file, then rebuild and restart my instance, but it doesn’t work. Do you have an idea how to fix it?

Hello @John_Morren and @bruce,

Sure :grinning:, many.

Maybe you need to also modify the nginx configuration under bitwarden/nginx/config/default.conf.search for location / and change it to location /bitwarden. I’ve not tested it since I have little time right now (hope you understand).

I’ve posted (some time ago) a possible contribution that could solve this problem :slight_smile: (see link below).

Anyway if you can also just use a subdomain (like: bitwarden.example.com) I have a working solution here:
https://github.com/Pulsar/bitwarden-compose-example

Hope this helps, when I will find time,

I did some googling around in the mean time and went on a little nginx learning journey.
I now know what a reverse proxy is and have written a little blog post on how I set it up.

@John_Morren if you still haven’t solved this yet, I recommend you to check out the blog post but instead of using a subdomain, doing what @Pulsar recommended and changing the location / to location /bitwarden in the config file you’ll be writing.

Update

Tested solution

Change only the nginx configuration for it to work. The global.override.env won’t help.
On the file bwdata/nginx/default.conf, change line 35 from this:

location / { ... }

to this:

location /bitwarden { ... }

or whatever you wish :slight_smile:.

Hope this helps
PS: Sorry for late reply, My laptop got some Juice and took time to buy new parts.

@Pulsar - Thanks. I apologize for my late response. My kid has been sick. I am just now circling back. I will let you know if this works.

@Pulsar - This seems to be working.

@John_Morren,
you’re welcome, I’m happy to help.

I know I’m late to the party, but unfortunately there not been any development regarding the subfolder problem, so I’m struggling with it today.

Concerning changing nginx config: I saw this comment at the top of the file when I double-checked after changing it and restarting the containers:

#######################################################################
# WARNING: This file is generated. Do not make changes to this file.  #
# They will be overwritten on update. You can manage various settings #
# used in this file from the ./bwdata/config.yml file for your        #
# installation.                                                       #
#######################################################################

Obviously the changes get overridden by some ./bitwarden.sh command, so this doesn’t seem to be a satisfactory solution.

Hello @gruentee,

yes, the will replace the file when you update. The script downloads a container that runs a compiled C# program. They use handlebars to replace each parameter. I suggest you put your configuration under a git repository and when you run the update you can see what changes are done and then keep what you want and discard the rest of the changes.

Another way would be to put another reverse proxy in front of bitwarden proxy. With that you redirect the location /bitwarden to where you want it to. I personally use a subdomain to redirect to bitwarden.

If you want, check out the example I’ve created for bitwarden:

I wanted to refactor it (clean it up) so that it would be much easier to work with it.

1 Like

Hi, thanks for your response.
I already have a reverse proxy running in front of Bitwarden’s Docker setup: HAProxy.

I finally added a rule to filter requests based on Referer-Header and rewrite requests coming from Bitwarden accordingly. Might not be the most secure option, but since I’m in a private network I think it’s okay.