settings.rst 20 KB

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