mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-12-11 09:13:02 +03:00
Actual client ip for websocket connections not showing up in logs #1471
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mustaphazorgati on GitHub.
Subject of the issue
Your environment
Steps to reproduce
start bitwarden normally and enable websocket.
docker-compose file:
forward X-Real-IP from caddy to bitwardenrs
caddy config:
Expected behaviour
The real client ip should show up in bitwardenrs log for websocket and regular logs.
Actual behaviour
The real client ip only shows up for regular logs, not for websocket logs. There the ip
172.19.0.1shows up. (see below)Relevant logs
@stefan0xC commented on GitHub:
@mustaphazorgati You are right. Sorry, I should have checked my own logs. (Because I have the same problem with nginx on host and bitwarden_rs.)
@mustaphazorgati commented on GitHub:
Hey @stefan0xC,
thanks for your short reply. According to caddy's documentation the
X-Forwarded-Forheader is set. I've tried to set that header manually, but that won't work.Regarding the IP address: No, I am using bitwarden_rs with docker, not caddy.
@stefan0xC commented on GitHub:
According to docs.rs/parity_ws the client_addr function looks for the
X-Forwarded-Forheader to look up the IP of a client. So probably caddy does not implicitly set the right address.172.19.0.1looks like a docker address. Are you running caddy inside a container? Can you set this header manually?@ak2k commented on GitHub:
Does anyone with a better understanding of how this function is used in bitwarden_rs have a theory about why this isn't working as expected, given that the function is indeed documented to (and the source seems consistent with the documentation) pass the X-Forwarded-For header, yet doesn't seem to be doing so as used in bitwarden_rs?
@BlackDex commented on GitHub:
Not sure if we can fix this. This is a message from a third party library.
They do not use these headers. Also not sure if they are willing to accept PR's for this, since they created this as a short term fix waiting for its upstream source to merge a PR.
@BlackDex commented on GitHub:
If you want to to be fixed, make sure that you add
x-forwarded-forheader at the reverse proxy.The websocket library only supports that specific header.
@Masgalor commented on GitHub:
I do not know much about caddy, but would not the optimal solution be to add support for the (HA)proxy-protocol?
Link for reference Link
@mustaphazorgati commented on GitHub:
@BlackDex: Caddy already sets that header automatically. See: https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#headers
@BlackDex commented on GitHub:
Ok, i have checked the source code a bit better now, and that part of the code is not even used at all where i saw the
x-fowarded-forheader, it even has#[allow(dead_code)]defined there 🙄.So, this is really not something we can fix, as this is all inside the provided library.
I have created a FAQ item at the WIKI. https://github.com/dani-garcia/vaultwarden/wiki/FAQs