settings.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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 ``SEARXNG_SETTINGS_PATH`` environment variable.
  19. 2. ``/etc/searxng/settings.yml``
  20. If these files don't exist (or are empty or can't be read), SearXNG 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. issue_url: https://github.com/searxng/searxng/issues
  32. docs_url: https://docs.searxng.org
  33. public_instances: https://searx.space
  34. wiki_url: https://github.com/searxng/searxng/wiki
  35. ``issue_url`` :
  36. If you host your own issue tracker change this URL.
  37. ``docs_url`` :
  38. If you host your own documentation change this URL.
  39. ``public_instances`` :
  40. If you host your own https://searx.space change this URL.
  41. ``wiki_url`` :
  42. Link to your wiki (or ``false``)
  43. .. _settings global general:
  44. ``general:``
  45. ------------
  46. .. code:: yaml
  47. general:
  48. debug: false # Debug mode, only for development
  49. instance_name: "SearXNG" # displayed name
  50. contact_url: false # mailto:contact@example.com
  51. ``debug`` : ``$SEARXNG_DEBUG``
  52. Allow a more detailed log if you run SearXNG directly. Display *detailed* error
  53. messages in the browser too, so this must be deactivated in production.
  54. ``contact_url``:
  55. Contact ``mailto:`` address or WEB form.
  56. ``enable_metrics``:
  57. Enabled by default. Record various anonymous metrics availabled at ``/stats``,
  58. ``/stats/errors`` and ``/preferences``.
  59. .. _settings global server:
  60. ``server:``
  61. -----------
  62. .. code:: yaml
  63. server:
  64. base_url: false # set custom base_url (or false)
  65. port: 8888
  66. bind_address: "127.0.0.1" # address to listen on
  67. secret_key: "ultrasecretkey" # change this!
  68. image_proxy: false # proxying image results through SearXNG
  69. default_locale: "" # default interface locale
  70. default_theme: oscar # ui theme
  71. default_http_headers:
  72. X-Content-Type-Options : nosniff
  73. X-XSS-Protection : 1; mode=block
  74. X-Download-Options : noopen
  75. X-Robots-Tag : noindex, nofollow
  76. Referrer-Policy : no-referrer
  77. .. sidebar:: buildenv
  78. Changing a value tagged by :ref:`buildenv <make buildenv>`, needs to
  79. rebuild instance's environment :ref:`utils/brand.env <make buildenv>`.
  80. ``base_url`` : :ref:`buildenv SEARXNG_URL <make buildenv>`
  81. The base URL where SearXNG is deployed. Used to create correct inbound links.
  82. If you change the value, don't forget to rebuild instance's environment
  83. (:ref:`utils/brand.env <make buildenv>`)
  84. ``port`` & ``bind_address``: :ref:`buildenv SEARXNG_PORT & SEARXNG_BIND_ADDRESS <make buildenv>`
  85. Port number and *bind address* of the SearXNG web application if you run it
  86. directly using ``python searx/webapp.py``. Doesn't apply to SearXNG running on
  87. Apache or Nginx.
  88. ``secret_key`` : ``$SEARXNG_SECRET``
  89. Used for cryptography purpose.
  90. ``image_proxy`` :
  91. Allow your instance of SearXNG of being able to proxy images. Uses memory space.
  92. ``default_locale`` :
  93. SearXNG interface language. If blank, the locale is detected by using the
  94. browser language. If it doesn't work, or you are deploying a language
  95. specific instance of searx, a locale can be defined using an ISO language
  96. code, like ``fr``, ``en``, ``de``.
  97. ``default_theme`` :
  98. Name of the theme you want to use by default on your SearXNG instance.
  99. .. _HTTP headers: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
  100. ``default_http_headers``:
  101. Set additional HTTP headers, see `#755 <https://github.com/searx/searx/issues/715>`__
  102. .. _settings redis:
  103. ``redis:``
  104. ----------
  105. .. _Redis.from_url(url): https://redis-py.readthedocs.io/en/stable/connections.html#redis.client.Redis.from_url
  106. ``url``
  107. URL to connect redis database, see `Redis.from_url(url)`_ & :ref:`redis db`::
  108. redis://[[username]:[password]]@localhost:6379/0
  109. rediss://[[username]:[password]]@localhost:6379/0
  110. unix://[[username]:[password]]@/path/to/socket.sock?db=0
  111. .. admonition:: Tip for developers
  112. To set up a redis instance simply use::
  113. $ ./manage redis.build
  114. $ sudo -H ./manage redis.install
  115. To get access rights to this instance, your developer account needs to be
  116. added to the *searxng-redis* group::
  117. $ sudo -H ./manage redis.addgrp "${USER}"
  118. # don't forget to logout & login to get member of group
  119. .. _settings outgoing:
  120. ``outgoing:``
  121. -------------
  122. Communication with search engines.
  123. .. code:: yaml
  124. outgoing:
  125. request_timeout: 2.0 # default timeout in seconds, can be override by engine
  126. max_request_timeout: 10.0 # the maximum timeout in seconds
  127. useragent_suffix: "" # informations like an email address to the administrator
  128. pool_connections: 100 # Maximum number of allowable connections, or null
  129. # for no limits. The default is 100.
  130. pool_maxsize: 10 # Number of allowable keep-alive connections, or null
  131. # to always allow. The default is 10.
  132. enable_http2: true # See https://www.python-httpx.org/http2/
  133. # uncomment below section if you want to use a proxy
  134. # proxies:
  135. # all://:
  136. # - http://proxy1:8080
  137. # - http://proxy2:8080
  138. # uncomment below section only if you have more than one network interface
  139. # which can be the source of outgoing search requests
  140. # source_ips:
  141. # - 1.1.1.1
  142. # - 1.1.1.2
  143. # - fe80::/126
  144. ``request_timeout`` :
  145. Global timeout of the requests made to others engines in seconds. A bigger
  146. timeout will allow to wait for answers from slow engines, but in consequence
  147. will slow SearXNG reactivity (the result page may take the time specified in the
  148. timeout to load). Can be override by :ref:`settings engine`
  149. ``useragent_suffix`` :
  150. Suffix to the user-agent SearXNG uses to send requests to others engines. If an
  151. engine wish to block you, a contact info here may be useful to avoid that.
  152. ``keepalive_expiry``:
  153. Number of seconds to keep a connection in the pool. By default 5.0 seconds.
  154. .. _httpx proxies: https://www.python-httpx.org/advanced/#http-proxying
  155. ``proxies`` :
  156. Define one or more proxies you wish to use, see `httpx proxies`_.
  157. If there are more than one proxy for one protocol (http, https),
  158. requests to the engines are distributed in a round-robin fashion.
  159. ``source_ips`` :
  160. If you use multiple network interfaces, define from which IP the requests must
  161. be made. Example:
  162. * ``0.0.0.0`` any local IPv4 address.
  163. * ``::`` any local IPv6 address.
  164. * ``192.168.0.1``
  165. * ``[ 192.168.0.1, 192.168.0.2 ]`` these two specific IP addresses
  166. * ``fe80::60a2:1691:e5a2:ee1f``
  167. * ``fe80::60a2:1691:e5a2:ee1f/126`` all IP addresses in this network.
  168. * ``[ 192.168.0.1, fe80::/126 ]``
  169. ``retries`` :
  170. Number of retry in case of an HTTP error. On each retry, SearXNG uses an
  171. different proxy and source ip.
  172. ``retry_on_http_error`` :
  173. Retry request on some HTTP status code.
  174. Example:
  175. * ``true`` : on HTTP status code between 400 and 599.
  176. * ``403`` : on HTTP status code 403.
  177. * ``[403, 429]``: on HTTP status code 403 and 429.
  178. ``enable_http2`` :
  179. Enable by default. Set to ``false`` to disable HTTP/2.
  180. ``max_redirects`` :
  181. 30 by default. Maximum redirect before it is an error.
  182. ``categories_as_tabs:``
  183. -----------------------
  184. A list of the categories that are displayed as tabs in the user interface.
  185. Categories not listed here can still be searched with the :ref:`search-syntax`.
  186. .. code-block:: yaml
  187. categories_as_tabs:
  188. general:
  189. images:
  190. videos:
  191. news:
  192. map:
  193. music:
  194. it:
  195. science:
  196. files:
  197. social media:
  198. .. _settings engine:
  199. Engine settings
  200. ===============
  201. .. sidebar:: Further reading ..
  202. - :ref:`configured engines`
  203. - :ref:`engines-dev`
  204. In the code example below a *full fledged* example of a YAML setup from a dummy
  205. engine is shown. Most of the options have a default value or even are optional.
  206. .. code:: yaml
  207. - name: example engine
  208. engine: example
  209. shortcut: demo
  210. base_url: 'https://{language}.example.com/'
  211. categories: general
  212. timeout: 3.0
  213. api_key: 'apikey'
  214. disabled: false
  215. language: en_US
  216. tokens: [ 'my-secret-token' ]
  217. weigth: 1
  218. display_error_messages: true
  219. about:
  220. website: https://example.com
  221. wikidata_id: Q306656
  222. official_api_documentation: https://example.com/api-doc
  223. use_official_api: true
  224. require_api_key: true
  225. results: HTML
  226. enable_http: false
  227. enable_http2: false
  228. retries: 1
  229. retry_on_http_error: true # or 403 or [404, 429]
  230. max_connections: 100
  231. max_keepalive_connections: 10
  232. keepalive_expiry: 5.0
  233. proxies:
  234. http:
  235. - http://proxy1:8080
  236. - http://proxy2:8080
  237. https:
  238. - http://proxy1:8080
  239. - http://proxy2:8080
  240. - socks5://user:password@proxy3:1080
  241. - socks5h://user:password@proxy4:1080
  242. ``name`` :
  243. Name that will be used across SearXNG to define this engine. In settings, on
  244. the result page...
  245. ``engine`` :
  246. Name of the python file used to handle requests and responses to and from this
  247. search engine.
  248. ``shortcut`` :
  249. Code used to execute bang requests (in this case using ``!bi``)
  250. ``base_url`` : optional
  251. Part of the URL that should be stable across every request. Can be useful to
  252. use multiple sites using only one engine, or updating the site URL without
  253. touching at the code.
  254. ``categories`` : optional
  255. Define in which categories this engine will be active. Most of the time, it is
  256. defined in the code of the engine, but in a few cases it is useful, like when
  257. describing multiple search engine using the same code.
  258. ``timeout`` : optional
  259. Timeout of the search with the current search engine. **Be careful, it will
  260. modify the global timeout of SearXNG.**
  261. ``api_key`` : optional
  262. In a few cases, using an API needs the use of a secret key. How to obtain them
  263. is described in the file.
  264. ``disabled`` : optional
  265. To disable by default the engine, but not deleting it. It will allow the user
  266. to manually activate it in the settings.
  267. ``language`` : optional
  268. If you want to use another language for a specific engine, you can define it
  269. by using the full ISO code of language and country, like ``fr_FR``, ``en_US``,
  270. ``de_DE``.
  271. ``tokens`` : optional
  272. A list of secret tokens to make this engine *private*, more details see
  273. :ref:`private engines`.
  274. ``weigth`` : default ``1``
  275. Weighting of the results of this engine.
  276. ``display_error_messages`` : default ``true``
  277. When an engine returns an error, the message is displayed on the user interface.
  278. ``network``: optional
  279. Use the network configuration from another engine.
  280. In addition, there are two default networks:
  281. * ``ipv4`` set ``local_addresses`` to ``0.0.0.0`` (use only IPv4 local addresses)
  282. * ``ipv6`` set ``local_addresses`` to ``::`` (use only IPv6 local addresses)
  283. .. note::
  284. A few more options are possible, but they are pretty specific to some
  285. engines, and so won't be described here.
  286. Example: Multilingual Search
  287. ----------------------------
  288. SearXNG does not support true multilingual search. You have to use the language
  289. prefix in your search query when searching in a different language.
  290. But there is a workaround: By adding a new search engine with a different
  291. language, SearXNG will search in your default and other language.
  292. Example configuration in settings.yml for a German and English speaker:
  293. .. code-block:: yaml
  294. search:
  295. default_lang : "de"
  296. ...
  297. engines:
  298. - name : google english
  299. engine : google
  300. language : en
  301. ...
  302. When searching, the default google engine will return German results and
  303. "google english" will return English results.
  304. .. _settings use_default_settings:
  305. use_default_settings
  306. ====================
  307. .. sidebar:: ``use_default_settings: true``
  308. - :ref:`settings location`
  309. - :ref:`use_default_settings.yml`
  310. - :origin:`/etc/searxng/settings.yml <utils/templates/etc/searxng/settings.yml>`
  311. The user defined ``settings.yml`` is loaded from the :ref:`settings location`
  312. and can relied on the default configuration :origin:`searx/settings.yml` using:
  313. ``use_default_settings: true``
  314. ``server:``
  315. In the following example, the actual settings are the default settings defined
  316. in :origin:`searx/settings.yml` with the exception of the ``secret_key`` and
  317. the ``bind_address``:
  318. .. code-block:: yaml
  319. use_default_settings: true
  320. server:
  321. secret_key: "ultrasecretkey" # change this!
  322. bind_address: "0.0.0.0"
  323. ``engines:``
  324. With ``use_default_settings: true``, each settings can be override in a
  325. similar way, the ``engines`` section is merged according to the engine
  326. ``name``. In this example, SearXNG will load all the engine and the arch linux
  327. wiki engine has a :ref:`token <private engines>`:
  328. .. code-block:: yaml
  329. use_default_settings: true
  330. server:
  331. secret_key: "ultrasecretkey" # change this!
  332. engines:
  333. - name: arch linux wiki
  334. tokens: ['$ecretValue']
  335. ``engines:`` / ``remove:``
  336. It is possible to remove some engines from the default settings. The following
  337. example is similar to the above one, but SearXNG doesn't load the the google
  338. engine:
  339. .. code-block:: yaml
  340. use_default_settings:
  341. engines:
  342. remove:
  343. - google
  344. server:
  345. secret_key: "ultrasecretkey" # change this!
  346. engines:
  347. - name: arch linux wiki
  348. tokens: ['$ecretValue']
  349. ``engines:`` / ``keep_only:``
  350. As an alternative, it is possible to specify the engines to keep. In the
  351. following example, SearXNG has only two engines:
  352. .. code-block:: yaml
  353. use_default_settings:
  354. engines:
  355. keep_only:
  356. - google
  357. - duckduckgo
  358. server:
  359. secret_key: "ultrasecretkey" # change this!
  360. engines:
  361. - name: google
  362. tokens: ['$ecretValue']
  363. - name: duckduckgo
  364. tokens: ['$ecretValue']