on master help sign in
[doc] recommend to use 'use_default_settings=True'

Since #2291 is merged, it is recommend to use:: use_default_settings=True 1. Add a template file use_default_settings.yml:: SEARX_SETTINGS_TEMPLATE="${REPO_ROOT}/utils/templates/etc/searx/use_default_settings.yml" 2. In Chapter "Configuration" recommend to make use of 'use_default_settings=True' and describe it 3. Rewrite of docs/admin/settings.rst - move chapter 'settings.yml location' to the top - update and split chapter 'Global Settings' 4. Add environment SEARX_SETTINGS_TEMPLATE to .config.sh 5. Use environment $SEARX_SETTINGS_TEMPLATE in the utils/searx.sh script Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>

commita70b9b9f616d75507bd404f036b95ce91cefefa4 authorMarkus Heiser <markus.heiser@darmarit.de> dateTue 8 Dec 2020, 20:19 (6 years ago) parentc1a9732
6 files changed+175−95
.config.sh+1 docs/admin/installation-searx.rst+25−4 docs/admin/settings.rst+102−83 docs/build-templates/searx.rst+18−2 utils/searx.sh+7−6 utils/templates/etc/searx/use_default_settings.yml+22
.config.sh+1
@@ -26,6 +26,7 @@ fi
2626# ---------
2727
2828# SEARX_INTERNAL_URL="127.0.0.1:8888"
29+# SEARX_SETTINGS_TEMPLATE="${REPO_ROOT}/utils/templates/etc/searx/use_default_settings.yml"
2930
3031# Only change, if you maintain a searx brand in your searx fork.
3132# GIT_BRANCH="${GIT_BRANCH:-master}"
docs/admin/installation-searx.rst+25−4
@@ -64,17 +64,38 @@ from the login (*~/.profile*):
6464 Open a second terminal for the configuration tasks and left the ``(searx)$``
6565 terminal open for the tasks below.
6666
67+
68+.. _use_default_settings.yml:
69+
6770Configuration
68−==============
71+=============
72+
73+To create a initial ``/etc/searx/settings.yml`` you can start with a copy of the
74+file :origin:`utils/templates/etc/searx/use_default_settings.yml`. This setup
75+:option:ref:`use default settings <settings use_default_settings>` from
76+:origin:`searx/settings.yml` and is recommended since :pull:`2291` is merged.
6977
70−Create a copy of the :origin:`searx/settings.yml` configuration file in system's
71−*/etc* folder. Configure like shown below -- replace ``searx@\$(uname -n)`` with
72−a name of your choice -- *and/or* edit ``/etc/searx/settings.yml`` if necessary.
78+For minimal Setup, configure like shown below – replace ``searx@\$(uname -n)``
79+with a name of your choice, set ``ultrasecretkey`` -- *and/or* edit
80+``/etc/searx/settings.yml`` to your needs.
7381
7482.. kernel-include:: $DOCS_BUILD/includes/searx.rst
7583 :start-after: START searx config
7684 :end-before: END searx config
7785
86+.. tabs::
87+
88+ .. group-tab:: Use default settings
89+
90+ .. literalinclude:: ../../utils/templates/etc/searx/use_default_settings.yml
91+ :language: yaml
92+
93+ .. group-tab:: searx/settings.yml
94+
95+ .. literalinclude:: ../../searx/settings.yml
96+ :language: yaml
97+
98+
7899Check
79100=====
80101
docs/admin/settings.rst+102−83
@@ -9,6 +9,7 @@ file.
99
1010.. sidebar:: Further reading ..
1111
12+ - :ref:`use_default_settings.yml`
1213 - :ref:`search API`
1314
1415.. contents:: Contents
@@ -16,92 +17,61 @@ file.
1617 :local:
1718 :backlinks: entry
1819
19−.. _settings global:
20+.. _settings location:
2021
21−Global Settings
22−===============
22+settings.yml location
23+=====================
2324
24−.. code:: yaml
25+First, searx will try to load settings.yml from these locations:
2526
26− server:
27− port : 8888
28− secret_key : "ultrasecretkey" # change this!
29− debug : False # debug mode, only for development
30− request_timeout : 2.0 # seconds
31− base_url : False # set custom base_url (or False)
32− themes_path : "" # custom ui themes path
33− default_theme : oscar # ui theme
34− useragent_suffix : "" # suffix of searx_useragent, could contain
35− # informations like admins email address
36− image_proxy : False # proxying image results through searx
37− default_locale : "" # default interface locale
27+1. the full path specified in the ``SEARX_SETTINGS_PATH`` environment variable.
28+2. ``/etc/searx/settings.yml``
3829
39− outgoing: # communication with search engines
40− request_timeout : 2.0 # default timeout in seconds, can be override by engine
41− # max_request_timeout: 10.0 # the maximum timeout in seconds
42− useragent_suffix : "" # suffix of searx_useragent, could contain informations like an email address to the administrator
43− pool_connections : 100 # Number of different hosts
44− pool_maxsize : 10 # Number of simultaneous requests by host
45−
46− #proxies:
47− # http:
48− # - http://proxy1:8080
49− # - http://proxy2:8080
50− # https:
51− # - http://proxy1:8080
52− # - http://proxy2:8080
53− # - socks5://user:password@proxy3:1080
54− # - socks5h://user:password@proxy4:1080
55−
56− #source_ips:
57− # - 1.1.1.1
58− # - 1.1.1.2
30+If these files don't exist (or are empty or can't be read), searx uses the :origin:`searx/settings.yml` file.
5931
60− locales:
61− en : English
62− de : Deutsch
63− he : Hebrew
64− hu : Magyar
65− fr : Français
66− es : Español
67− it : Italiano
68− nl : Nederlands
69− ja : 日本語 (Japanese)
70− tr : Türkçe
71− ru : Russian
72− ro : Romanian
7332
33+.. _settings global:
7434
75−``port`` :
76− Port number of the searx web application if you run it directly using ``python
77− searx/webapp.py``. Doesn't apply to searx running on Apache or Nginx.
35+Global Settings
36+===============
7837
79−``secret_key`` :
80− Used for cryptography purpose.
38+.. code:: yaml
39+
40+ general:
41+ debug : False # Debug mode, only for development
42+ instance_name : "searx" # displayed name
8143
8244``debug`` :
8345 Allow a more detailed log if you run searx directly. Display *detailed* error
8446 messages in the browser too, so this must be deactivated in production.
8547
86−``request_timeout`` :
87− Global timeout of the requests made to others engines in seconds. A bigger
88− timeout will allow to wait for answers from slow engines, but in consequence
89− will slow searx reactivity (the result page may take the time specified in the
90− timeout to load)
91−
92−``base_url`` :
93− The base URL where searx is deployed. Used to create correct inbound links.
48+.. code:: yaml
9449
95−``themes_path`` :
96− Path to where the themes are located. If you didn't develop anything, leave it
97− blank.
50+ server:
51+ port : 8888
52+ bind_address : "127.0.0.1" # address to listen on
53+ secret_key : "ultrasecretkey" # change this!
54+ base_url : False # set custom base_url (or False)
55+ image_proxy : False # proxying image results through searx
56+ default_locale : "" # default interface locale
57+ default_theme : oscar # ui theme
58+ default_http_headers:
59+ X-Content-Type-Options : nosniff
60+ X-XSS-Protection : 1; mode=block
61+ X-Download-Options : noopen
62+ X-Robots-Tag : noindex, nofollow
63+ Referrer-Policy : no-referrer
64+
65+``port`` & ``bind_address``:
66+ Port number and *bind address* of the searx web application if you run it
67+ directly using ``python searx/webapp.py``. Doesn't apply to searx running on
68+ Apache or Nginx.
9869
99−``default_theme`` :
100− Name of the theme you want to use by default on your searx instance.
70+``secret_key`` :
71+ Used for cryptography purpose.
10172
102−``useragent_suffix`` :
103− Suffix to the user-agent searx uses to send requests to others engines. If an
104− engine wish to block you, a contact info here may be useful to avoid that.
73+``base_url`` :
74+ The base URL where searx is deployed. Used to create correct inbound links.
10575
10676``image_proxy`` :
10777 Allow your instance of searx of being able to proxy images. Uses memory space.
@@ -112,6 +82,48 @@ Global Settings
11282 specific instance of searx, a locale can be defined using an ISO language
11383 code, like ``fr``, ``en``, ``de``.
11484
85+``default_theme`` :
86+ Name of the theme you want to use by default on your searx instance.
87+
88+.. _HTTP headers: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
89+
90+``default_http_headers``:
91+ Set additional HTTP headers, see `#755 <https://github.com/searx/searx/issues/715>`__
92+
93+
94+.. code:: yaml
95+
96+ outgoing: # communication with search engines
97+ request_timeout : 2.0 # default timeout in seconds, can be override by engine
98+ # max_request_timeout: 10.0 # the maximum timeout in seconds
99+ useragent_suffix : "" # informations like an email address to the administrator
100+ pool_connections : 100 # Number of different hosts
101+ pool_maxsize : 10 # Number of simultaneous requests by host
102+ # uncomment below section if you want to use a proxy
103+ # proxies:
104+ # http:
105+ # - http://proxy1:8080
106+ # - http://proxy2:8080
107+ # https:
108+ # - http://proxy1:8080
109+ # - http://proxy2:8080
110+ # uncomment below section only if you have more than one network interface
111+ # which can be the source of outgoing search requests
112+ # source_ips:
113+ # - 1.1.1.1
114+ # - 1.1.1.2
115+
116+
117+``request_timeout`` :
118+ Global timeout of the requests made to others engines in seconds. A bigger
119+ timeout will allow to wait for answers from slow engines, but in consequence
120+ will slow searx reactivity (the result page may take the time specified in the
121+ timeout to load). Can be override by :ref:`settings engine`
122+
123+``useragent_suffix`` :
124+ Suffix to the user-agent searx uses to send requests to others engines. If an
125+ engine wish to block you, a contact info here may be useful to avoid that.
126+
115127.. _requests proxies: https://requests.readthedocs.io/en/latest/user/advanced/#proxies
116128.. _PySocks: https://pypi.org/project/PySocks/
117129
@@ -120,10 +132,29 @@ Global Settings
120132 If there are more than one proxy for one protocol (http, https),
121133 requests to the engines are distributed in a round-robin fashion.
122134
135+ - Proxy: `see <https://2.python-requests.org/en/latest/user/advanced/#proxies>`__.
136+ - SOCKS proxies are also supported: `see <https://2.python-requests.org/en/latest/user/advanced/#socks>`__
137+
123138``source_ips`` :
124139 If you use multiple network interfaces, define from which IP the requests must
125140 be made. This parameter is ignored when ``proxies`` is set.
126141
142+.. code:: yaml
143+
144+ locales:
145+ en : English
146+ de : Deutsch
147+ he : Hebrew
148+ hu : Magyar
149+ fr : Français
150+ es : Español
151+ it : Italiano
152+ nl : Nederlands
153+ ja : 日本語 (Japanese)
154+ tr : Türkçe
155+ ru : Russian
156+ ro : Romanian
157+
127158``locales`` :
128159 Locales codes and their names. Available translations of searx interface.
129160
@@ -208,19 +239,7 @@ Engine settings
208239 engines, and so won't be described here.
209240
210241
211−.. _settings location:
212−
213−settings.yml location
214−=====================
215−
216−First, searx will try to load settings.yml from these locations:
217−
218−1. the full path specified in the ``SEARX_SETTINGS_PATH`` environment variable.
219−2. ``/etc/searx/settings.yml``
220−
221−If these files don't exist (or are empty or can't be read), searx uses the :origin:`searx/settings.yml` file.
222−
223−.. _ settings use_default_settings:
242+.. _settings use_default_settings:
224243
225244use_default_settings
226245====================
docs/build-templates/searx.rst+18−2
@@ -128,12 +128,28 @@ ${fedora_build}
128128
129129.. tabs::
130130
131− .. group-tab:: bash
131+ .. group-tab:: Use default settings
132+
133+ .. code-block:: sh
134+
135+ $ sudo -H mkdir -p \"$(dirname ${SEARX_SETTINGS_PATH})\"
136+ $ sudo -H cp \"$SEARX_SRC/utils/templates/etc/searx/use_default_settings.yml\" \\
137+ \"${SEARX_SETTINGS_PATH}\"
138+
139+ .. group-tab:: searx/settings.yml
132140
133141 .. code-block:: sh
134142
135143 $ sudo -H mkdir -p \"$(dirname ${SEARX_SETTINGS_PATH})\"
136− $ sudo -H cp \"$SEARX_SRC/searx/settings.yml\" \"${SEARX_SETTINGS_PATH}\"
144+ $ sudo -H cp \"$SEARX_SRC/searx/settings.yml\" \\
145+ \"${SEARX_SETTINGS_PATH}\"
146+
147+.. tabs::
148+
149+ .. group-tab:: minimal setup
150+
151+ .. code-block:: sh
152+
137153 $ sudo -H sed -i -e \"s/ultrasecretkey/\$(openssl rand -hex 16)/g\" \"$SEARX_SETTINGS_PATH\"
138154 $ sudo -H sed -i -e \"s/{instance_name}/searx@\$(uname -n)/g\" \"$SEARX_SETTINGS_PATH\"
139155
utils/searx.sh+7−6
@@ -36,6 +36,7 @@ GIT_BRANCH="${GIT_BRANCH:-master}"
3636SEARX_PYENV="${SERVICE_HOME}/searx-pyenv"
3737SEARX_SRC="${SERVICE_HOME}/searx-src"
3838SEARX_SETTINGS_PATH="/etc/searx/settings.yml"
39+SEARX_SETTINGS_TEMPLATE="${REPO_ROOT}/utils/templates/etc/searx/use_default_settings.yml"
3940SEARX_UWSGI_APP="searx.ini"
4041# shellcheck disable=SC2034
4142SEARX_UWSGI_SOCKET="/run/uwsgi/app/searx/socket"
@@ -139,7 +140,7 @@ usage() {
139140 cat <<EOF
140141usage::
141142 $(basename "$0") shell
142− $(basename "$0") install [all|user|searx-src|pyenv|uwsgi|packages|buildhost]
143+ $(basename "$0") install [all|user|searx-src|pyenv|uwsgi|packages|settings|buildhost]
143144 $(basename "$0") update [searx]
144145 $(basename "$0") remove [all|user|pyenv|searx-src]
145146 $(basename "$0") activate [service]
@@ -413,14 +414,14 @@ install_settings() {
413414 if [[ ! -f ${SEARX_SETTINGS_PATH} ]]; then
414415 info_msg "install settings ${REPO_ROOT}/searx/settings.yml"
415416 info_msg " --> ${SEARX_SETTINGS_PATH}"
416− cp "${REPO_ROOT}/searx/settings.yml" "${SEARX_SETTINGS_PATH}"
417+ cp "${SEARX_SETTINGS_TEMPLATE}" "${SEARX_SETTINGS_PATH}"
417418 configure_searx
418419 return
419420 fi
420421
421422 rst_para "Diff between origin's setting file (+) and current (-):"
422− echo
423− $DIFF_CMD "${SEARX_SETTINGS_PATH}" "${SEARX_SRC}/searx/settings.yml"
423+ echo "${SEARX_SETTINGS_PATH}" "${SEARX_SETTINGS_TEMPLATE}"
424+ $DIFF_CMD "${SEARX_SETTINGS_PATH}" "${SEARX_SETTINGS_TEMPLATE}"
424425
425426 local action
426427 choose_one action "What should happen to the settings file? " \
@@ -434,7 +435,7 @@ install_settings() {
434435 "use origin settings")
435436 backup_file "${SEARX_SETTINGS_PATH}"
436437 info_msg "install origin settings"
437− cp "${SEARX_SRC}/searx/settings.yml" "${SEARX_SETTINGS_PATH}"
438+ cp "${SEARX_SETTINGS_TEMPLATE}" "${SEARX_SETTINGS_PATH}"
438439 ;;
439440 "start interactiv shell")
440441 backup_file "${SEARX_SETTINGS_PATH}"
@@ -442,7 +443,7 @@ install_settings() {
442443 sudo -H -i
443444 rst_para 'Diff between new setting file (-) and current (+):'
444445 echo
445− $DIFF_CMD "${SEARX_SRC}/searx/settings.yml" "${SEARX_SETTINGS_PATH}"
446+ $DIFF_CMD "${SEARX_SETTINGS_TEMPLATE}" "${SEARX_SETTINGS_PATH}"
446447 wait_key
447448 ;;
448449 esac
utils/templates/etc/searx/use_default_settings.ymlnew file+22
@@ -0,0 +1,22 @@
1+use_default_settings: True
2+
3+general:
4+ debug : False # Debug mode, only for development
5+ instance_name : "searx" # displayed name
6+
7+search:
8+ safe_search : 0 # Filter results. 0: None, 1: Moderate, 2: Strict
9+ autocomplete : "" # Existing autocomplete backends: "dbpedia", "duckduckgo", "google", "startpage", "swisscows", "qwant", "wikipedia" - leave blank to turn it off by default
10+ default_lang : "" # Default search language - leave blank to detect from browser information or use codes from 'languages.py'
11+
12+server:
13+ port : 8888
14+ bind_address : "127.0.0.1" # address to listen on
15+ secret_key : "ultrasecretkey" # change this!
16+ base_url : False # Set custom base_url. Possible values: False or "https://your.custom.host/location/"
17+ image_proxy : False # Proxying image results through searx
18+
19+# uncomment below section if you have running morty proxy
20+#result_proxy:
21+# url : http://127.0.0.1:3000/
22+# key : !!binary "your_morty_proxy_key"