[Need help] Reverse proxy w/ Let's Encrypt & Bitwarden & Nextcloud


Recommended Posts

unRaid 6.7.2

 

First time unRaid user, currently on a test key however I've always wanted to host bitwarden myself. I've been watching and following this guide from u/spaceinvaderone however while he uses Nextcloud and sonarr as an example, I'm using bitwarden.

Most things go to plan, Let's encrypt give my domain my own cert (Although I already own a wildcard so it would be good to just use that one if I can? however when I go to bitwarden.mydomain.com I get the ngix landing page for Let's encrypt which falls under appdata\letsencrypt\www\index.html

 

It appears while everything works correctly with Let's Encrypt and the domain, it is not forwarding the domain to the correct port of bitwarden. I tried to edit the /appdata/letsencrypt/nginx/proxy-confs/bitwarden.subdomain.conf file with:
 

server {

listen 443;

 

server_name bitwarden.*;

 

include /config/nginx/ssl.conf;

 

client_max_body_size 128M;

# enable for ldap auth, fill in ldap details in ldap.conf

#include /config/nginx/ldap.conf;


location / {

include /config/nginx/proxy.conf;

proxy_pass http://172.20.55.109:8080;

}


location /notifications/hub {

include /config/nginx/proxy.conf;

proxy_pass http://172.20.55.109:8080;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "Upgrade";

}


location /notifications/hub/negotiate {

include /config/nginx/proxy.conf;

proxy_pass http://172.20.55.109:8080;

}

}

without luck, even after rebooting both the Let's Encrypt docker and also the server itself, this page shows up externally on my mobile when connected via LTE so the pfsense rules are working as they should, something isn't forwarding correctly.

 

Can anyone see what's going wrong here? This happens with both nextcloud AND bitwarden, therefore it seems there is an issue with ngix within Let's Encrypt.
Thinking there was an issue, I reinstalled unRaid however ran into the same issue.

 

1.webp 2.webp 3.webp 4.webp

Link to comment
  • 5 months later...

Hi

Here is my conf for bitwarden.

Make sure your bitwarden container is named "bitwarden"

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name bitwarden.*;

    include /config/nginx/ssl.conf;

    client_max_body_size 128M;

    # enable for ldap auth, fill in ldap details in ldap.conf
    #include /config/nginx/ldap.conf;

    location / {
        # enable the next two lines for http auth
        #auth_basic "Restricted";
        #auth_basic_user_file /config/nginx/.htpasswd;

        # enable the next two lines for ldap auth
        #auth_request /auth;
        #error_page 401 =200 /login;

        include /config/nginx/proxy.conf;
        resolver 127.0.0.11 valid=30s;
        set $upstream_bitwarden bitwarden;
        proxy_pass http://$upstream_bitwarden:80;
    }

    location /notifications/hub {
        include /config/nginx/proxy.conf;
        resolver 127.0.0.11 valid=30s;
        set $upstream_bitwarden bitwarden;
        proxy_pass http://$upstream_bitwarden:80;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }

    location /notifications/hub/negotiate {
        include /config/nginx/proxy.conf;
        resolver 127.0.0.11 valid=30s;
        set $upstream_bitwarden bitwarden;
        proxy_pass http://$upstream_bitwarden:80;
    }

}

 

Link to comment
#BITWARDEN
# make sure that your domain has dns has a cname or a record set for the subdomain bitwarden 
# This config file will work as is when using a custom docker network the same as letesencrypt (proxynet).
# However the container name is expected to be "bitwardenrs" as it is by default the template as this name is used to resolve.  
# If you are not using the custom docker network for this container then change the line "server bitwardenrs:80;" to "server [YOUR_SERVER_IP]:8086;" 
Also remove line 7

resolver 127.0.0.11 valid=30s;
upstream bitwarden {
    server bitwardenrs:80;
}

server {
    listen 443 ssl;
    server_name mynamebitwarden.*;
    include /config/nginx/ssl.conf;
  client_max_body_size 128M;

  location / {
   proxy_pass http://bitwarden;
    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;
  }
  
  location /notifications/hub {
   proxy_pass http://bitwarden;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
  }
  
  location /notifications/hub/negotiate {
    proxy_pass http://bitwarden;
  }
}

This is what Spaceinvadore shared, it looks different than your config file. I only changed the subdomain as you see. it is added to duckdns and letencript

my bitwarden container name is bitwardens as default. 

should i just copy and past your configuration? of course i will change the subdomain and will change the container to bitwarden instead.

 

Link to comment

I took the default file from letsencrypt\nginx\proxy-confs\bitwarden.subdomain.conf.sample, renamed it bitwarden.subdomain.conf and rename my image docker name from bitwardenrs to bitwarden.
Did you create a custom netowrk as it's explained in the spaceinvader video ? Do you opened the ports in your router ? Does it work for another container ?

Link to comment

I opened port 80 and 443 just like he showed in video. Is there another port to open?

I tried your config file. Changed the name of the docker as you instructed. It still not working. 
I have my Nextcloud working, at least it created an Https with duckdns and I can access from out side. Although there is errors in next cloud about rever proxy I don’t know what it means. 
anyway. Is your bitwarden works fine using your domain. 

Link to comment

I followed Spaceinvador’s YouTube video step by step. The only difference I am seeing reading the forum and space invader is that I am using DuckDns to creat my subdomain and I guess everyone else is using their payed domain. 
duckdns is setup right and running on unraid

letencrypt running with no error  
and the config file is set up with the subdomain. I don’t know what else I am missing. 

Link to comment

Hi deadnote, first thanks for trying to help me.

i decided to have my own domain to try and see if bitwarden would work. i will write all the steps and please let me know if i am missing something.

first, I know that Letenrypt is set up right with my domain name and subdomains, the log connected to all my 2 subdomain Nextcloud, bitwarden. see image. made sure the Cnam is set right spelled right...

 

Second, my duckdns is set up right since my Nextcloud is working following Spaceenvador's Video

for Bitwarden, yes i set up the network to custom,  just like Nextcloud.

I tried 2 different config files in letencryp for bitwarden, one with spaceinvador file and i left the  container name as original with bitwardenrs

of course i alway restart my dockers.

 

#BITWARDEN
# make sure that your domain has dns has a cname or a record set for the subdomain bitwarden 
# This config file will work as is when using a custom docker network the same as letesencrypt (proxynet).
# However the container name is expected to be "bitwardenrs" as it is by default the template as this name is used to resolve.  
# If you are not using the custom docker network for this container then change the line "server bitwardenrs:80;" to "server [YOUR_SERVER_IP]:8086;" Also remove line 7

resolver 127.0.0.11 valid=30s;
upstream bitwarden {
    server bitwardenrs:80;
}

server {
    listen 443 ssl;
    server_name bitwarden.*;
    include /config/nginx/ssl.conf;
  client_max_body_size 128M;

  location / {
   proxy_pass http://bitwarden;
    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;
  }
  
  location /notifications/hub {
   proxy_pass http://bitwarden;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
  }
  
  location /notifications/hub/negotiate {
    proxy_pass http://bitwarden;
  }
}

second i tried you config which is the same as what was in letenrypt and change .sample to .conf and i change the container name to bitwarden.

 

# make sure that your dns has a cname set for bitwarden and that your bitwarden container is not using a base url
# make sure your bitwarden container is named "bitwarden"

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name bitwarden.*;

    include /config/nginx/ssl.conf;

    client_max_body_size 128M;

    # enable for ldap auth, fill in ldap details in ldap.conf
    #include /config/nginx/ldap.conf;

    location / {
        # enable the next two lines for http auth
        #auth_basic "Restricted";
        #auth_basic_user_file /config/nginx/.htpasswd;

        # enable the next two lines for ldap auth
        #auth_request /auth;
        #error_page 401 =200 /login;

        include /config/nginx/proxy.conf;
        resolver 127.0.0.11 valid=30s;
        set $upstream_app bitwarden;
        set $upstream_port 80;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port;

    }

    location /notifications/hub {
        include /config/nginx/proxy.conf;
        resolver 127.0.0.11 valid=30s;
        set $upstream_app bitwarden;
        set $upstream_port 80;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port;

        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }

    location /notifications/hub/negotiate {
        include /config/nginx/proxy.conf;
        resolver 127.0.0.11 valid=30s;
        set $upstream_app bitwarden;
        set $upstream_port 80;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port;

    }

}

 

now the weird part. when i use http://bitwarden.mydomain.com it will direct me to nextcloud i don't understand why?, when i stop nextcloud and try again i have error 502 Bad Gateway nginx/1.16.1

i am able only to connect locally with bitwarden i dont know what am i missing. this was the same using duckdns as domain

Capture.PNG

Edited by ssinseeme
name
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.