-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
feat(lib): Improve remote address handling and overwritecondaddr checks #45651
base: master
Are you sure you want to change the base?
feat(lib): Improve remote address handling and overwritecondaddr checks #45651
Conversation
…header Signed-off-by: Alexander Schieweck <[email protected]>
Signed-off-by: Alexander Schieweck <[email protected]>
Signed-off-by: Alexander Schieweck <[email protected]>
Signed-off-by: Alexander Schieweck <[email protected]>
Signed-off-by: Alexander Schieweck <[email protected]>
Hi @kesselb, any thoughts on the idea or the current state of this PR? |
Thanks for your pull request 👍 I'm unsure if we should have two default What is your use case for |
The My use case for allowing proxies in the |
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
Just merged the current state of the master branch into this one. I hope this should fix most of the checks, as they failed on some setup procedures, i.e. running composer. I haven't touched composer things in this PR, so I'm a bit lost while this wouldn't work. |
Yep, some of our CI have issues with forks. It looks like a reasonable change. We need the ip addresse for the brute force detection, and thus it makes sense to also check the reverse proxy for the overwritecondaddr. We only take trusted proxies into account.
What would you like to change? I'm just wondering because most of the use cases for overwritecondaddr are usually look like hack. Do you set a different hostname if the request is coming through cf? |
OK, I had a look at the failing checks, and I'd say the failures are due to the CI & fork thing. Nothing related to this PR. But please let me know if there is a check, I should have a closer look at
This PR is only looking at the remote address report and the chain of trusted proxies. Let's say we have a request with the following header information: Client - Proxy 1 - Trusted Proxy 1 - Proxy 2 - Trusted Proxy 2 - Trusted Proxy 3 - Nextcloud. Then
That's exactly it. The cleanest way would be to have separate domain and path settings based on the upstream proxy. But that sound like a lot of work for a very niche problem. I'm happy with some jankiness and understand that this isn't a common (or even supported) use case. |
Hello @nickvergessen & @Altahrim! Do you guys have any feedback on this? |
Summary
This PR has two related improvements:
overwritecondaddr
regex from the config against the remote address AND the trusted proxy chain.I ran into a similar issue as danielwbn in #6914. My remote address is always the IP of the client, which is great and shows that my reverse proxy is working, but I need to set specific overrides depending on the proxy route the request has taken.
The
isOverwriteCondition()
method was using the direct call to theserver['REMOTE_ADDR'])
instead of thegetRemoteAddress()
method. As both methods would need to interact with the trusted proxies and the headers, I refactored this part out into a common method. This can now also handle both styles of forward headers used by reverse proxies.TODO
Checklist
Screenshots before/after for front-end changes