settings.rst 16 KB

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