__init__.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # SPDX-License-Identifier: AGPL-3.0-or-later
  2. # lint: pylint
  3. """.. _botdetection src:
  4. The :ref:`limiter <limiter src>` implements several methods to block bots:
  5. a. Analysis of the HTTP header in the request / can be easily bypassed.
  6. b. Block and pass lists in which IPs are listed / difficult to maintain, since
  7. the IPs of bots are not all known and change over the time.
  8. c. Detection of bots based on the behavior of the requests and blocking and, if
  9. necessary, unblocking of the IPs via a dynamically changeable IP block list.
  10. For dynamically changeable IP lists a Redis database is needed and for any kind
  11. of IP list the determination of the IP of the client is essential. The IP of
  12. the client is determined via the X-Forwarded-For_ HTTP header
  13. .. _X-Forwarded-For:
  14. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For
  15. X-Forwarded-For
  16. ===============
  17. .. attention::
  18. A correct setup of the HTTP request headers ``X-Forwarded-For`` and
  19. ``X-Real-IP`` is essential to be able to assign a request to an IP correctly:
  20. - `NGINX RequestHeader`_
  21. - `Apache RequestHeader`_
  22. .. _NGINX RequestHeader:
  23. https://docs.searxng.org/admin/installation-nginx.html#nginx-s-searxng-site
  24. .. _Apache RequestHeader:
  25. https://docs.searxng.org/admin/installation-apache.html#apache-s-searxng-site
  26. .. autofunction:: searx.botdetection.get_real_ip
  27. """
  28. from ._helpers import dump_request
  29. from ._helpers import get_real_ip
  30. from ._helpers import too_many_requests