-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
problem with rewritten IP #13
Comments
It really just depends on what the headers of your request look like. Once you know that, tracing through the algorithm will tell you how RemoteIp came to its conclusion. That's the easier part: the harder part is knowing which layers in your system added which headers and when. Off the top of my head, it could be that the multiple headers are being parsed in an order that doesn't preserve the "hops" correctly (which, to be fair, is kind of impossible for RemoteIp to detect, AFAICT). Logging could help (like I said in #6). Really, I should just wire up logging statements in the RemoteIp code so users can easily trace its execution when they're debugging their setups like this. 🤔 |
I managed to make it work. My problem was that I was using this outside of the normal plug, inside the error_handler in the router. |
This makes the code a bit more verbose, but I figure it will help users troubleshoot their configurations as easily as possible (cf. #6, #13). This was also my main reason for factoring out %RemoteIp.Config{}, since it makes the logs simpler to grok (seeing a pretty struct vs some arbitrarily formatted string).
even though I get the right IP in the "x-forwarded-for" header, the remote IP is not rewritten properly. Maybe an additional header is problematic here? (I'm behind cloudfllare)
Here is what I get
remote_ip is {10, 255, 0, 2}
forwarded IP, 197.245.12.24
Here is my config (I just took this from somebody else using cloudflare)
am I missing something?
The text was updated successfully, but these errors were encountered: