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.
Could anyone help me to setup? Thank you very much.
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/) then you can tell nginx to serve bitwarden when you access the website through this URL.
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 (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:
server {
server_name bitwarden.example.tld;
return 301 https://bitwarden.example.tld$request_uri;
}
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.