[GH-ISSUE #303] ignoring X-Forwarded-For headers? #163

Closed
opened 2026-03-03 01:26:12 +03:00 by kerem · 5 comments
Owner

Originally created by @tycho on GitHub (Dec 17, 2018).
Original GitHub issue: https://github.com/dani-garcia/vaultwarden/issues/303

I notice that when using a reverse proxy, bitwarden_rs logs the wrong IP address:

[2018-12-17][09:47:45][bitwarden_rs::api::identity][ERROR] Username or password is incorrect. Try again. IP: 127.0.0.1. Username: ...

This is especially sloppy looking since that error message gets surfaced to the user on the web vault.

My reverse proxy is setting the X-Forwarded-For header, but it seems that bitwarden_rs doesn't pay attention to that when determining the client IP?

Originally created by @tycho on GitHub (Dec 17, 2018). Original GitHub issue: https://github.com/dani-garcia/vaultwarden/issues/303 I notice that when using a reverse proxy, bitwarden_rs logs the wrong IP address: `[2018-12-17][09:47:45][bitwarden_rs::api::identity][ERROR] Username or password is incorrect. Try again. IP: 127.0.0.1. Username: ...` This is especially sloppy looking since that error message gets surfaced to the user on the web vault. My reverse proxy is setting the `X-Forwarded-For` header, but it seems that bitwarden_rs doesn't pay attention to that when determining the client IP?
kerem closed this issue 2026-03-03 01:26:13 +03:00
Author
Owner

@dani-garcia commented on GitHub (Dec 17, 2018):

Rocket uses X-Real-IP for retrieving the clients IP address, instead of X-Forwarded-For.

The error message comes from a time where we didn't have any decent logging in place, but it could be changed now to hide that info from the user.

<!-- gh-comment-id:447940456 --> @dani-garcia commented on GitHub (Dec 17, 2018): Rocket uses `X-Real-IP` for retrieving the clients IP address, instead of `X-Forwarded-For`. The error message comes from a time where we didn't have any decent logging in place, but it could be changed now to hide that info from the user.
Author
Owner

@tycho commented on GitHub (Dec 17, 2018):

Yep, I switched to X-Real-IP and that works! Thanks!

<!-- gh-comment-id:447940873 --> @tycho commented on GitHub (Dec 17, 2018): Yep, I switched to `X-Real-IP` and that works! Thanks!
Author
Owner

@tycho commented on GitHub (Dec 17, 2018):

Oh, maybe the PROXY.md should make mention of the X-Real-IP thing. Here's what I did for nginx:

proxy_set_header X-Real-IP $proxy_add_x_forwarded_for;
<!-- gh-comment-id:447943065 --> @tycho commented on GitHub (Dec 17, 2018): Oh, maybe the `PROXY.md` should make mention of the `X-Real-IP` thing. Here's what I did for nginx: ``` proxy_set_header X-Real-IP $proxy_add_x_forwarded_for; ```
Author
Owner

@dani-garcia commented on GitHub (Dec 17, 2018):

True, I use Caddy which does this by default, so I didn't know. What do you think of adding these (to be equivalent with what Caddy sends)?

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;
<!-- gh-comment-id:447946691 --> @dani-garcia commented on GitHub (Dec 17, 2018): True, I use Caddy which does this by default, so I didn't know. What do you think of adding these (to be equivalent with what Caddy sends)? ``` 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; ```
Author
Owner

@tycho commented on GitHub (Dec 17, 2018):

Seems reasonable to me!

<!-- gh-comment-id:447947899 --> @tycho commented on GitHub (Dec 17, 2018): Seems reasonable to me!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vaultwarden#163
No description provided.