HTTPS nginx configuration

Hello.

I’m trying to set up Bitwarden on existing nginx server. Connection through HTTP is ok. But on HTTPS i’m getting ERR_CONNECTION_REFUSED. What’s wrong with my confs?

What i’ve changed from default configuration:
1.Changed http and https ports in config.yml file.
2.Turned off ssl in config.yml because nginx with ssl already exists.
3. Added two server blocks to nginx configuration file.(see below).

Thanks for help.

server {
    listen 443 ssl;
    server_name bitwarden.johnnyluger.tech;

    ssl_certificate /root/.acme.sh/johnnyluger.tech/fullchain.cer; # use fullchain.cer for complete certificate;
    ssl_certificate_key /root/.acme.sh/johnnyluger.tech/johnnyluger.tech.key; # keep this private as much as possible;

    location / {
        proxy_pass http://localhost:44399/;
    }
}

server {
    if ($host = bitwarden.johnnyluger.tech) {
        return 301 https://$host$request_uri;
    }

    listen 80;
    listen [::]:80;

    server_name bitwarden.johnnyluger.tech;
    return 404; # managed by Certbot
}

And config.yml changes

# Docker compose file port mapping for HTTP. Leave empty to remove the port mapping.
# Learn more: https://docs.docker.com/compose/compose-file/#ports
http_port: 999
#
# Docker compose file port mapping for HTTPS. Leave empty to remove the port mapping.
# Learn more: https://docs.docker.com/compose/compose-file/#ports
https_port: 44399
#
# Docker compose file version. Leave empty for default.
# Learn more: https://docs.docker.com/compose/compose-file/compose-versioning/
compose_version:
#
# Configure Nginx for Captcha.
captcha: false
#
# Configure Nginx for SSL.
ssl: false

Hi @POLPAKETA94 - welcome to the community forums! And I am very sorry to hear about your issues installing Bitwarden server.

Can you tell us which version of BW server you are trying to install as well as which install script you are using? Also, what kind of device are you installing to (e.g., Windows PC, Linux PC, etc.). With a bit more information, perhaps someone here can help. Cheers!

Hi.
I’ve installed Bitwarden according this manual
https://bitwarden.com/help/install-on-premise-linux/
OS: Ubuntu 20.04

This is redirecting to the HTTPS port of Bitwarden, but you disabled SSL.

Since your nginx proxy is taking care of SSL, you can simply locally route the traffic to Bitwarden via HTTP, in your case to port 999.

Make sure to either block port 999 from external access with a firewall, or to bind it to localhost only, e.g. http_port: 127.0.0.1:999.

Changing the port helped solve the problem. Thanks a lot.

1 Like

Hi @POLPAKETA94, how did you manage to disable the integrated nginx server? I cant seem to stop bitwarden from spinning up its own…