mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-02-05 00:29:40 +03:00
Client IP not logging correctly in logs #636
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 @karrots on GitHub (Mar 4, 2020).
While attempting to validate the fail2ban setup I noticed that real IP addresses are not being shown correctly in the log files. I do have the
transparentdirective in theCaddyfilefor each proxy entry. Myconfig.jsonspecifiesX-Forwarded-ForandX-Real-IPboth had the same outcome.Your environment
Steps to reproduce
Setup per instructions at link https://github.com/dani-garcia/bitwarden_rs/wiki/Using-Docker-Compose
Expected behavior
Should show actual client IP addresses as listed in the
X-Real-IPorX-Forwarded-Forheaders.Actual behavior
Shows internal Docker IP addresses.
Relevant logs
[error][ERROR] Username or password is incorrect. Try again. IP: 192.168.32.1. Username: example@example.com@BlackDex commented on GitHub (Mar 5, 2020):
What does the log file of caddy tell you where the connection is coming from? Try to enable logging for caddy if it is not already.
@BlackDex commented on GitHub (Mar 5, 2020):
Also for a short while, try to increase the log_level of bitwarden_rs to trace. This should show all the headers received during the request.
@jjlin commented on GitHub (Mar 5, 2020):
I don't think this is a bitwarden_rs issue. You probably need https://caddyserver.com/v1/docs/http.realip.
@karrots commented on GitHub (Mar 5, 2020):
@jjlin your suggestion would be correct if I were running another proxy in front of Caddy and using Caddy as an HTTP server. I'm using Caddy as a reverse proxy to bitwarden_rs there is no other proxy in front of Caddy to add the X-Forwarded-For header in.
@BlackDex using trace level I am seeing the X-Real-Ip header with the docker private IP addresses. So it seems the issue is with the docker networking when using docker-compose. I'll have to see if I can find anything on this elsewhere.
Sample from log file.
"X-Real-Ip"=[49, 57, 50, 46, 49, 54, 56, 46, 51, 50, 46, 49]@karrots commented on GitHub (Mar 5, 2020):
Fix is to specify host mode for the exposed ports.
https://github.com/moby/moby/issues/25526#issuecomment-463668116
In my
docker-compose.ymlI did it like this. If you have a newer docker-compose that supports the extended format mentioned in the link above you may not need to specify the host IP.