# Nginx setup for server already use port 80 and 443

**URL:** <https://vaultwarden.discourse.group/t/nginx-setup-for-server-already-use-port-80-and-443/746>\
**Category:** Help\
**Created:** [March 21, 2021, 3:22am UTC](https://vaultwarden.discourse.group/t/nginx-setup-for-server-already-use-port-80-and-443/746 "2021-03-21T03:22:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![quyleanh](https://avatars.discourse-cdn.com/v4/letter/q/85e7bf/32.png) [@quyleanh](https://vaultwarden.discourse.group/u/quyleanh)\
**Post date:** [March 21, 2021, 3:22am UTC](https://vaultwarden.discourse.group/t/nginx-setup-for-server-already-use-port-80-and-443/746/1 "2021-03-21T03:22:13Z")

</div>

I have plan to install `bitwardenrs` on my server, which already use port 80 and 443 for my website.  
The link should be like this: `https://bitwarden.example.tld/`

Since I am newbie with docker, I don’t know what to do when I read the nginx proxy example on [wiki page](https://github.com/dani-garcia/bitwarden_rs/wiki/Proxy-examples).

Could anyone help me to setup? Thank you very much.

---

<div class="post-metadata">

**Author:** ![simias](https://yyz2.discourse-cdn.com/free1/user_avatar/vaultwarden.discourse.group/simias/32/274_2.png) [@simias](https://vaultwarden.discourse.group/u/simias)\
**Post date:** [March 21, 2021, 3:11pm UTC](https://vaultwarden.discourse.group/t/nginx-setup-for-server-already-use-port-80-and-443/746/2 "2021-03-21T15:11:35Z")

</div>

There are several ways to go, personally I’d just create a new subdomain dedicated to bitwarden (which appears to be what you want with [https://bitwarden.example.tld/](https://bitwarden.example.tld/)) then you can tell nginx to serve bitwarden when you access the website through this URL.

Roughly speaking I start my container like so:

`docker run -d --name bitwarden -e WEBSOCKET_ENABLED=true -v /path/to/bitwarden/data:/data/ -p 127.0.0.1:1234:80 -p 127.0.0.1:3012:3012 bitwardenrs/server:latest`

Note the `-p 127.0.0.1:1234:80` that rebinds the bitwarden’s 80 port to port 1234 in the host machine, and makes sure it only binds localhost so that it can’t be reached from the outside. That assumes of course that nginx will be running on the same machine.

Then you can configure your nginx as explained here, taking care to replace the `proxy_pass` statements to use port 1234 instead of 80, and `<SERVER>` should be 127.0.0.1: [Proxy examples · dani-garcia/bitwarden\_rs Wiki · GitHub](https://github.com/dani-garcia/bitwarden_rs/wiki/Proxy-examples) (the “Nginx (by shauder)” one should do the trick).

Make sure to only allow HTTPS connections to the bitwarden instance. You can redirect HTTP to HTTPS with something like:

```auto
    server {
        server_name bitwarden.example.tld;
        return 301 https://bitwarden.example.tld$request_uri;
    }

```

I hope that helps.

---

<div class="post-metadata">

**Author:** ![simias](https://yyz2.discourse-cdn.com/free1/user_avatar/vaultwarden.discourse.group/simias/32/274_2.png) [@simias](https://vaultwarden.discourse.group/u/simias)\
**Post date:** [March 22, 2021, 11:58am UTC](https://vaultwarden.discourse.group/t/nginx-setup-for-server-already-use-port-80-and-443/746/4 "2021-03-22T11:58:22Z")

</div>

Be careful, you haven’t set 127.0.0.1 in your -p specification when starting the docker image, which _I think_ means that the port will be reachable from the outside directly without going through nginx, unless I misunderstand the way containers bind their ports (very possible) or if you have a firewall running.
