settings.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. .. _settings.yml:
  2. ================
  3. ``settings.yml``
  4. ================
  5. This page describe the options possibilities of the :origin:`searx/settings.yml`
  6. file.
  7. .. sidebar:: Further reading ..
  8. - :ref:`use_default_settings.yml`
  9. - :ref:`search API`
  10. .. contents:: Contents
  11. :depth: 2
  12. :local:
  13. :backlinks: entry
  14. .. _settings location:
  15. settings.yml location
  16. =====================
  17. The initial ``settings.yml`` we be load from these locations:
  18. 1. the full path specified in the ``SEARX_SETTINGS_PATH`` environment variable.
  19. 2. ``/etc/searx/settings.yml``
  20. If these files don't exist (or are empty or can't be read), searx uses the
  21. :origin:`searx/settings.yml` file. Read :ref:`settings use_default_settings` to
  22. see how you can simplify your *user defined* ``settings.yml``.
  23. .. _settings global:
  24. Global Settings
  25. ===============
  26. .. _settings global brand:
  27. ``brand:``
  28. ------------
  29. .. code:: yaml
  30. brand:
  31. git_url: https://github.com/searxng/searxng
  32. git_branch: master
  33. issue_url: https://github.com/searxng/searxng/issues
  34. docs_url: https://searxng/searxng.github.io/searxng
  35. public_instances: https://searx.space
  36. wiki_url: https://github.com/searxng/searxng/wiki
  37. .. sidebar:: buildenv
  38. Changing a value tagged by :ref:`buildenv <make buildenv>`, needs to
  39. rebuild instance's environment :ref:`utils/brand.env <make buildenv>`.
  40. ``git_url`` & ``git_branch`` : :ref:`buildenv GIT_URL & GIT_BRANCH <make buildenv>`
  41. Changes this, to point to your searx fork (branch).
  42. ``issue_url`` :
  43. If you host your own issue tracker change this URL.
  44. ``docs_url`` :
  45. If you host your own documentation change this URL.
  46. ``public_instances`` :
  47. If you host your own https://searx.space change this URL.
  48. ``wiki_url`` :
  49. Link to your wiki (or ``false``)
  50. .. _settings global general:
  51. ``general:``
  52. ------------
  53. .. code:: yaml
  54. general:
  55. debug: false # Debug mode, only for development
  56. instance_name: "searxng" # displayed name
  57. contact_url: false # mailto:contact@example.com
  58. ``debug`` : ``$SEARX_DEBUG``
  59. Allow a more detailed log if you run searx directly. Display *detailed* error
  60. messages in the browser too, so this must be deactivated in production.
  61. ``contact_url``:
  62. Contact ``mailto:`` address or WEB form.
  63. .. _settings global server:
  64. ``server:``
  65. -----------
  66. .. code:: yaml
  67. server:
  68. base_url: false # set custom base_url (or false)
  69. port: 8888
  70. bind_address: "127.0.0.1" # address to listen on
  71. secret_key: "ultrasecretkey" # change this!
  72. image_proxy: false # proxying image results through searx
  73. default_locale: "" # default interface locale
  74. default_theme: oscar # ui theme
  75. default_http_headers:
  76. X-Content-Type-Options : nosniff
  77. X-XSS-Protection : 1; mode=block
  78. X-Download-Options : noopen
  79. X-Robots-Tag : noindex, nofollow
  80. Referrer-Policy : no-referrer
  81. .. sidebar:: buildenv
  82. Changing a value tagged by :ref:`buildenv <make buildenv>`, needs to
  83. rebuild instance's environment :ref:`utils/brand.env <make buildenv>`.
  84. ``base_url`` : :ref:`buildenv SEARX_URL <make buildenv>`
  85. The base URL where searx is deployed. Used to create correct inbound links.
  86. If you change the value, don't forget to rebuild instance's environment
  87. (:ref:`utils/brand.env <make buildenv>`)
  88. ``port`` & ``bind_address``: :ref:`buildenv SEARX_PORT & SEARX_BIND_ADDRESS <make buildenv>`
  89. Port number and *bind address* of the searx web application if you run it
  90. directly using ``python searx/webapp.py``. Doesn't apply to searx running on
  91. Apache or Nginx.
  92. ``secret_key`` : ``$SEARX_SECRET``
  93. Used for cryptography purpose.
  94. ``image_proxy`` :
  95. Allow your instance of searx of being able to proxy images. Uses memory space.
  96. ``default_locale`` :
  97. Searx interface language. If blank, the locale is detected by using the
  98. browser language. If it doesn't work, or you are deploying a language
  99. specific instance of searx, a locale can be defined using an ISO language
  100. code, like ``fr``, ``en``, ``de``.
  101. ``default_theme`` :
  102. Name of the theme you want to use by default on your searx instance.
  103. .. _HTTP headers: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
  104. ``default_http_headers``:
  105. Set additional HTTP headers, see `#755 <https://github.com/searx/searx/issues/715>`__
  106. ``outgoing:``
  107. -------------
  108. Communication with search engines.
  109. .. code:: yaml
  110. outgoing:
  111. request_timeout: 2.0 # default timeout in seconds, can be override by engine
  112. max_request_timeout: 10.0 # the maximum timeout in seconds
  113. useragent_suffix: "" # informations like an email address to the administrator
  114. pool_connections: 100 # Maximum number of allowable connections, or null
  115. # for no limits. The default is 100.
  116. pool_maxsize: 10 # Number of allowable keep-alive connections, or null
  117. # to always allow. The default is 10.
  118. enable_http2: true # See https://www.python-httpx.org/http2/
  119. # uncomment below section if you want to use a proxy
  120. # proxies:
  121. # all://:
  122. # - http://proxy1:8080
  123. # - http://proxy2:8080
  124. # uncomment below section only if you have more than one network interface
  125. # which can be the source of outgoing search requests
  126. # source_ips:
  127. # - 1.1.1.1
  128. # - 1.1.1.2
  129. # - fe80::/126
  130. ``request_timeout`` :
  131. Global timeout of the requests made to others engines in seconds. A bigger
  132. timeout will allow to wait for answers from slow engines, but in consequence
  133. will slow searx reactivity (the result page may take the time specified in the
  134. timeout to load). Can be override by :ref:`settings engine`
  135. ``useragent_suffix`` :
  136. Suffix to the user-agent searx uses to send requests to others engines. If an
  137. engine wish to block you, a contact info here may be useful to avoid that.
  138. ``keepalive_expiry``:
  139. Number of seconds to keep a connection in the pool. By default 5.0 seconds.
  140. .. _httpx proxies: https://www.python-httpx.org/advanced/#http-proxying
  141. ``proxies`` :
  142. Define one or more proxies you wish to use, see `httpx proxies`_.
  143. If there are more than one proxy for one protocol (http, https),
  144. requests to the engines are distributed in a round-robin fashion.
  145. ``source_ips`` :
  146. If you use multiple network interfaces, define from which IP the requests must
  147. be made. Example:
  148. * ``0.0.0.0`` any local IPv4 address.
  149. * ``::`` any local IPv6 address.
  150. * ``192.168.0.1``
  151. * ``[ 192.168.0.1, 192.168.0.2 ]`` these two specific IP addresses
  152. * ``fe80::60a2:1691:e5a2:ee1f``
  153. * ``fe80::60a2:1691:e5a2:ee1f/126`` all IP addresses in this network.
  154. * ``[ 192.168.0.1, fe80::/126 ]``
  155. ``retries`` :
  156. Number of retry in case of an HTTP error. On each retry, searx uses an
  157. different proxy and source ip.
  158. ``retry_on_http_error`` :
  159. Retry request on some HTTP status code.
  160. Example:
  161. * ``true`` : on HTTP status code between 400 and 599.
  162. * ``403`` : on HTTP status code 403.
  163. * ``[403, 429]``: on HTTP status code 403 and 429.
  164. ``enable_http2`` :
  165. Enable by default. Set to ``false`` to disable HTTP/2.
  166. ``max_redirects`` :
  167. 30 by default. Maximum redirect before it is an error.
  168. ``locales:``
  169. ------------
  170. .. code:: yaml
  171. locales:
  172. en: English
  173. de: Deutsch
  174. he: Hebrew
  175. hu: Magyar
  176. fr: Français
  177. es: Español
  178. it: Italiano
  179. nl: Nederlands
  180. ja: 日本語 (Japanese)
  181. tr: Türkçe
  182. ru: Russian
  183. ro: Romanian
  184. ``locales`` :
  185. Locales codes and their names. Available translations of searx interface.
  186. .. _settings engine:
  187. Engine settings
  188. ===============
  189. .. sidebar:: Further reading ..
  190. - :ref:`configured engines`
  191. - :ref:`engines-dev`
  192. In the code example below a *full fledged* example of a YAML setup from a dummy
  193. engine is shown. Most of the options have a default value or even are optional.
  194. .. code:: yaml
  195. - name: example engine
  196. engine: example
  197. shortcut: demo
  198. base_url: 'https://{language}.example.com/'
  199. categories: general
  200. timeout: 3.0
  201. api_key: 'apikey'
  202. disabled: false
  203. language: en_US
  204. tokens: [ 'my-secret-token' ]
  205. weigth: 1
  206. display_error_messages: true
  207. about:
  208. website: https://example.com
  209. wikidata_id: Q306656
  210. official_api_documentation: https://example.com/api-doc
  211. use_official_api: true
  212. require_api_key: true
  213. results: HTML
  214. enable_http: false
  215. enable_http2: false
  216. retries: 1
  217. retry_on_http_error: true # or 403 or [404, 429]
  218. max_connections: 100
  219. max_keepalive_connections: 10
  220. keepalive_expiry: 5.0
  221. proxies:
  222. http:
  223. - http://proxy1:8080
  224. - http://proxy2:8080
  225. https:
  226. - http://proxy1:8080
  227. - http://proxy2:8080
  228. - socks5://user:password@proxy3:1080
  229. - socks5h://user:password@proxy4:1080
  230. ``name`` :
  231. Name that will be used across searx to define this engine. In settings, on
  232. the result page...
  233. ``engine`` :
  234. Name of the python file used to handle requests and responses to and from this
  235. search engine.
  236. ``shortcut`` :
  237. Code used to execute bang requests (in this case using ``!bi`` or ``?bi``)
  238. ``base_url`` : optional
  239. Part of the URL that should be stable across every request. Can be useful to
  240. use multiple sites using only one engine, or updating the site URL without
  241. touching at the code.
  242. ``categories`` : optional
  243. Define in which categories this engine will be active. Most of the time, it is
  244. defined in the code of the engine, but in a few cases it is useful, like when
  245. describing multiple search engine using the same code.
  246. ``timeout`` : optional
  247. Timeout of the search with the current search engine. **Be careful, it will
  248. modify the global timeout of searx.**
  249. ``api_key`` : optional
  250. In a few cases, using an API needs the use of a secret key. How to obtain them
  251. is described in the file.
  252. ``disabled`` : optional
  253. To disable by default the engine, but not deleting it. It will allow the user
  254. to manually activate it in the settings.
  255. ``language`` : optional
  256. If you want to use another language for a specific engine, you can define it
  257. by using the full ISO code of language and country, like ``fr_FR``, ``en_US``,
  258. ``de_DE``.
  259. ``tokens`` : optional
  260. A list of secret tokens to make this engine *private*, more details see
  261. :ref:`private engines`.
  262. ``weigth`` : default ``1``
  263. Weighting of the results of this engine.
  264. ``display_error_messages`` : default ``true``
  265. When an engine returns an error, the message is displayed on the user interface.
  266. ``network``: optional
  267. Use the network configuration from another engine.
  268. In addition, there are two default networks:
  269. * ``ipv4`` set ``local_addresses`` to ``0.0.0.0`` (use only IPv4 local addresses)
  270. * ``ipv6`` set ``local_addresses`` to ``::`` (use only IPv6 local addresses)
  271. .. note::
  272. A few more options are possible, but they are pretty specific to some
  273. engines, and so won't be described here.
  274. .. _settings use_default_settings:
  275. use_default_settings
  276. ====================
  277. .. sidebar:: ``use_default_settings: true``
  278. - :ref:`settings location`
  279. - :ref:`use_default_settings.yml`
  280. - :origin:`/etc/searx/settings.yml <utils/templates/etc/searx/use_default_settings.yml>`
  281. The user defined ``settings.yml`` is loaded from the :ref:`settings location`
  282. and can relied on the default configuration :origin:`searx/settings.yml` using:
  283. ``use_default_settings: true``
  284. ``server:``
  285. In the following example, the actual settings are the default settings defined
  286. in :origin:`searx/settings.yml` with the exception of the ``secret_key`` and
  287. the ``bind_address``:
  288. .. code-block:: yaml
  289. use_default_settings: true
  290. server:
  291. secret_key: "ultrasecretkey" # change this!
  292. bind_address: "0.0.0.0"
  293. ``engines:``
  294. With ``use_default_settings: true``, each settings can be override in a
  295. similar way, the ``engines`` section is merged according to the engine
  296. ``name``. In this example, searx will load all the engine and the arch linux
  297. wiki engine has a :ref:`token <private engines>`:
  298. .. code-block:: yaml
  299. use_default_settings: true
  300. server:
  301. secret_key: "ultrasecretkey" # change this!
  302. engines:
  303. - name: arch linux wiki
  304. tokens: ['$ecretValue']
  305. ``engines:`` / ``remove:``
  306. It is possible to remove some engines from the default settings. The following
  307. example is similar to the above one, but searx doesn't load the the google
  308. engine:
  309. .. code-block:: yaml
  310. use_default_settings:
  311. engines:
  312. remove:
  313. - google
  314. server:
  315. secret_key: "ultrasecretkey" # change this!
  316. engines:
  317. - name: arch linux wiki
  318. tokens: ['$ecretValue']
  319. ``engines:`` / ``keep_only:``
  320. As an alternative, it is possible to specify the engines to keep. In the
  321. following example, searx has only two engines:
  322. .. code-block:: yaml
  323. use_default_settings:
  324. engines:
  325. keep_only:
  326. - google
  327. - duckduckgo
  328. server:
  329. secret_key: "ultrasecretkey" # change this!
  330. engines:
  331. - name: google
  332. tokens: ['$ecretValue']
  333. - name: duckduckgo
  334. tokens: ['$ecretValue']