-
Notifications
You must be signed in to change notification settings - Fork 13
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
An SecureClientIP with a priority fallback system #12
Comments
Hi :) Make sure you read the why different extractors section and understand the security implications of this approach. I believe in your situation it's better to use However, if you're sure, you can just copy the |
Hi, Thanks for the fast response. [Edit] |
Let's say you aren't behind CF, then someone could just add CF header to the request with any IP they want to trick the waterfall approach. |
Yes and no. |
I don't understand, aren't your trying to get a user ip? If so, how ip ranges of CF could help? |
The webserver, if not firewalled to allow only CF to proxy, could receive both with and without CF forwarding requests. If the latter one, it would break the code if using the Secure mode. X-Forwarded-For RFC states that it should append a IP of the Proxy server, and the Client IP either at the beginning or end of the list. To be sure the proxies forwarding are allowed to do so, there is mostly used a "whitelist" of the IP's (or CIDR range) that are valid to forward. For example, if I connect directly to the web server with CF enabled, would give me a error, but not when I connect through CloudFlare, thus in my opinion it should fallback to the Client IP it's connecting with. Another example, is that I could have my own VPS servers running a simple NGINX proxy forwarder, but I need to allow the use of X-Forwarded-For for those IP's that run my NGINX proxy. That's when a whitelist comes into play, that hold the IP ranges (handy in CIDR format) that are validated as legitimate sources. If you still need some info how others use this: |
Hi,
Is it possible to have something like:
CF Header > XRealIP > ConnectInfo
In this case, looking for the CF Header, and if that doesn't exist, try XRealIP, and if that doesn't exist, take the ConnectInfo IP address of client. Someway to add a priority lane, and if none of it works, giving a 500 error eventually to give up.
This would make it easy to host a server behind CloudFlare, but also make it work without CloudFLare.
Thanks !
The text was updated successfully, but these errors were encountered: