settings.rst 17 KB

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