-
Notifications
You must be signed in to change notification settings - Fork 315
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
Update Caddyfile to Add X-Real-IP to fix bot detection #162
Conversation
Bot detection complains about not having X-Real-IP which is required https://docs.searxng.org/src/searx.botdetection.html#id4 this adds the header and fixes the problem for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChillyKitty thanks a lot for adding X-Real-IP to the caddy config. I am not a docker expert and it would take too long to build my own testbed. So I'll just ask you directly, just to be sure:
a.) In the bot detection, the remote IP of the request is taken from (first match):
- X-Forwarded-For
- X-Real-IP
- flask.Request.remote_addr
Its documented here in the searx.botdetection.get_real_ip function.
b.) From the Caddy docs: .. sets or augments the X-Forwarded-For header field.
Can you confirm that X-Real-IP and X-Forwarded-For hold the same value (IP).
as far I can understand from the code, both |
not really request_ip = forwarded_for or real_ip or remote_addr or '0.0.0.0' but the code write log messages:
Reference: get_real_ip(request: flask.Request) |
This log makes This other log makes By de facto, I mean the user has to set these two headers to avoid tons of errors. |
To test start a `make run` instance and query multiple times for `ip` (the answerer), you should see only once the error message(s): ERROR searx.botdetection : X-Forwarded-For header is not set! ERROR searx.botdetection : X-Real-IP header is not set! [1] searxng/searxng-docker#174 [2] searxng/searxng-docker#162 (comment) Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Ah, OK .. sorry my slow comprehension .. now I understand what you mean / in my understanding of required I thought about the limiter works or not .. was not thinking about the massive error context 🤦 We can reduce the tons of error logs similar to what you suggested in #174 (reply in thread) .. I send PR .. does the PR mitigate the problem? / .. lets have further discussions in the PR. |
To test start a `make run` instance and query multiple times for `ip` (the answerer), you should see only once the error message(s): ERROR searx.botdetection : X-Forwarded-For header is not set! ERROR searx.botdetection : X-Real-IP header is not set! [1] searxng/searxng-docker#174 [2] searxng/searxng-docker#162 (comment) Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Bot detection complains about not having X-Real-IP which is required https://docs.searxng.org/src/searx.botdetection.html#id4 this adds the header and fixes the problem for me.