.oO SearXNG Developer Documentation Oo.
|
Public Member Functions | |
None | __init__ (self, WSGIApplication wsgi_app) |
list[IPv4Network|IPv6Network] | trusted_proxies (self) |
str | trusted_remote_addr (self, list[IPv4Address|IPv6Address] x_forwarded_for, list[IPv4Network|IPv6Network] trusted_proxies) |
abc.Iterable[bytes] | __call__ (self, WSGIEnvironment environ, StartResponse start_response) |
Public Attributes | |
wsgi_app = wsgi_app |
A middleware like the ProxyFix_ class, where the ``x_for`` argument is replaced by a method that determines the number of trusted proxies via the ``botdetection.trusted_proxies`` setting. .. sidebar:: :py:obj:`flask.Request.remote_addr` SearXNG uses Werkzeug's ProxyFix_ (with it default ``x_for=1``). The remote IP (:py:obj:`flask.Request.remote_addr`) of the request is taken from (first match): - X-Forwarded-For_: If the header is set, the first untrusted IP that comes before the IPs that are still part of the ``botdetection.trusted_proxies`` is used. - `X-Real-IP <https://github.com/searxng/searxng/issues/1237#issuecomment-1147564516>`__: If X-Forwarded-For_ is not set, `X-Real-IP` is used (``botdetection.trusted_proxies`` is ignored). If none of the header is set, the REMOTE_ADDR_ from the WSGI layer is used. If (for whatever reasons) none IP can be determined, an error message is displayed and ``100::`` is used instead (:rfc:`6666`). .. _ProxyFix: https://werkzeug.palletsprojects.com/middleware/proxy_fix/ .. _X-Forwarded-For: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For .. _REMOTE_ADDR: https://wsgi.readthedocs.io/en/latest/proposals-2.0.html#making-some-keys-required
Definition at line 22 of file trusted_proxies.py.
None searx.botdetection.trusted_proxies.ProxyFix.__init__ | ( | self, | |
WSGIApplication | wsgi_app ) |
Definition at line 57 of file trusted_proxies.py.
abc.Iterable[bytes] searx.botdetection.trusted_proxies.ProxyFix.__call__ | ( | self, | |
WSGIEnvironment | environ, | ||
StartResponse | start_response ) |
Definition at line 87 of file trusted_proxies.py.
References trusted_proxies(), trusted_remote_addr(), and wsgi_app.
list[IPv4Network | IPv6Network] searx.botdetection.trusted_proxies.ProxyFix.trusted_proxies | ( | self | ) |
Definition at line 60 of file trusted_proxies.py.
Referenced by __call__().
str searx.botdetection.trusted_proxies.ProxyFix.trusted_remote_addr | ( | self, | |
list[IPv4Address | IPv6Address] | x_forwarded_for, | ||
list[IPv4Network | IPv6Network] | trusted_proxies ) |
Definition at line 65 of file trusted_proxies.py.
Referenced by __call__().
searx.botdetection.trusted_proxies.ProxyFix.wsgi_app = wsgi_app |
Definition at line 58 of file trusted_proxies.py.
Referenced by __call__(), and searx.flaskfix.ReverseProxyPathFix.__call__().