on master help sign in
Merge pull request #2362 from return42/use_default_settings
35bf568Alexandre Flament
.config.sh+1
@@ -26,6 +26,7 @@ fi
26# ---------
26# ---------
27
27
28# SEARX_INTERNAL_URL="127.0.0.1:8888"
28# SEARX_INTERNAL_URL="127.0.0.1:8888"
29+# SEARX_SETTINGS_TEMPLATE="${REPO_ROOT}/utils/templates/etc/searx/use_default_settings.yml"
29
30
30# Only change, if you maintain a searx brand in your searx fork.
31# Only change, if you maintain a searx brand in your searx fork.
31# GIT_BRANCH="${GIT_BRANCH:-master}"
32# GIT_BRANCH="${GIT_BRANCH:-master}"
docs/admin/installation-searx.rst+25−4
@@ -64,17 +64,38 @@ from the login (*~/.profile*):
64 Open a second terminal for the configuration tasks and left the ``(searx)$``
64 Open a second terminal for the configuration tasks and left the ``(searx)$``
65 terminal open for the tasks below.
65 terminal open for the tasks below.
66
66
67+
68+.. _use_default_settings.yml:
69+
67Configuration
70Configuration
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.
69
77
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
78+For minimal Setup, configure like shown below – replace ``searx@\$(uname -n)``
72−a name of your choice -- *and/or* edit ``/etc/searx/settings.yml`` if necessary.
79+with a name of your choice, set ``ultrasecretkey`` -- *and/or* edit
80+``/etc/searx/settings.yml`` to your needs.
73
81
74.. kernel-include:: $DOCS_BUILD/includes/searx.rst
82.. kernel-include:: $DOCS_BUILD/includes/searx.rst
75 :start-after: START searx config
83 :start-after: START searx config
76 :end-before: END searx config
84 :end-before: END searx config
77
85
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+
78Check
99Check
79=====
100=====
80
101
docs/admin/settings.rst+102−83
@@ -9,6 +9,7 @@ file.
9
9
10.. sidebar:: Further reading ..
10.. sidebar:: Further reading ..
11
11
12+ - :ref:`use_default_settings.yml`
12 - :ref:`search API`
13 - :ref:`search API`
13
14
14.. contents:: Contents
15.. contents:: Contents
@@ -16,92 +17,61 @@ file.
16 :local:
17 :local:
17 :backlinks: entry
18 :backlinks: entry
18
19
19−.. _settings global:
20+.. _settings location:
20
21
21−Global Settings
22+settings.yml location
22−===============
23+=====================
23
24
24−.. code:: yaml
25+First, searx will try to load settings.yml from these locations:
25
26
26− server:
27+1. the full path specified in the ``SEARX_SETTINGS_PATH`` environment variable.
27− port : 8888
28+2. ``/etc/searx/settings.yml``
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
38
29
39− outgoing: # communication with search engines
30+If these files don't exist (or are empty or can't be read), searx uses the :origin:`searx/settings.yml` file.
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
59
31
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
73
32
33+.. _settings global:
74
34
75−``port`` :
35+Global Settings
76− Port number of the searx web application if you run it directly using ``python
36+===============
77− searx/webapp.py``. Doesn't apply to searx running on Apache or Nginx.
78
37
79−``secret_key`` :
38+.. code:: yaml
80− Used for cryptography purpose.
39+
40+ general:
41+ debug : False # Debug mode, only for development
42+ instance_name : "searx" # displayed name
81
43
82``debug`` :
44``debug`` :
83 Allow a more detailed log if you run searx directly. Display *detailed* error
45 Allow a more detailed log if you run searx directly. Display *detailed* error
84 messages in the browser too, so this must be deactivated in production.
46 messages in the browser too, so this must be deactivated in production.
85
47
86−``request_timeout`` :
48+.. code:: yaml
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.
94
49
95−``themes_path`` :
50+ server:
96− Path to where the themes are located. If you didn't develop anything, leave it
51+ port : 8888
97− blank.
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.
98
69
99−``default_theme`` :
70+``secret_key`` :
100− Name of the theme you want to use by default on your searx instance.
71+ Used for cryptography purpose.
101
72
102−``useragent_suffix`` :
73+``base_url`` :
103− Suffix to the user-agent searx uses to send requests to others engines. If an
74+ The base URL where searx is deployed. Used to create correct inbound links.
104− engine wish to block you, a contact info here may be useful to avoid that.
105
75
106``image_proxy`` :
76``image_proxy`` :
107 Allow your instance of searx of being able to proxy images. Uses memory space.
77 Allow your instance of searx of being able to proxy images. Uses memory space.
@@ -112,6 +82,48 @@ Global Settings
112 specific instance of searx, a locale can be defined using an ISO language
82 specific instance of searx, a locale can be defined using an ISO language
113 code, like ``fr``, ``en``, ``de``.
83 code, like ``fr``, ``en``, ``de``.
114
84
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+
115.. _requests proxies: https://requests.readthedocs.io/en/latest/user/advanced/#proxies
127.. _requests proxies: https://requests.readthedocs.io/en/latest/user/advanced/#proxies
116.. _PySocks: https://pypi.org/project/PySocks/
128.. _PySocks: https://pypi.org/project/PySocks/
117
129
@@ -120,10 +132,29 @@ Global Settings
120 If there are more than one proxy for one protocol (http, https),
132 If there are more than one proxy for one protocol (http, https),
121 requests to the engines are distributed in a round-robin fashion.
133 requests to the engines are distributed in a round-robin fashion.
122
134
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+
123``source_ips`` :
138``source_ips`` :
124 If you use multiple network interfaces, define from which IP the requests must
139 If you use multiple network interfaces, define from which IP the requests must
125 be made. This parameter is ignored when ``proxies`` is set.
140 be made. This parameter is ignored when ``proxies`` is set.
126
141
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+
127``locales`` :
158``locales`` :
128 Locales codes and their names. Available translations of searx interface.
159 Locales codes and their names. Available translations of searx interface.
129
160
@@ -208,19 +239,7 @@ Engine settings
208 engines, and so won't be described here.
239 engines, and so won't be described here.
209
240
210
241
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:
224
243
225use_default_settings
244use_default_settings
226====================
245====================
docs/build-templates/searx.rst+18−2
@@ -128,12 +128,28 @@ ${fedora_build}
128
128
129.. tabs::
129.. tabs::
130
130
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
132
140
133 .. code-block:: sh
141 .. code-block:: sh
134
142
135 $ sudo -H mkdir -p \"$(dirname ${SEARX_SETTINGS_PATH})\"
143 $ 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+
137 $ sudo -H sed -i -e \"s/ultrasecretkey/\$(openssl rand -hex 16)/g\" \"$SEARX_SETTINGS_PATH\"
153 $ sudo -H sed -i -e \"s/ultrasecretkey/\$(openssl rand -hex 16)/g\" \"$SEARX_SETTINGS_PATH\"
138 $ sudo -H sed -i -e \"s/{instance_name}/searx@\$(uname -n)/g\" \"$SEARX_SETTINGS_PATH\"
154 $ sudo -H sed -i -e \"s/{instance_name}/searx@\$(uname -n)/g\" \"$SEARX_SETTINGS_PATH\"
139
155
utils/searx.sh+7−6
@@ -36,6 +36,7 @@ GIT_BRANCH="${GIT_BRANCH:-master}"
36SEARX_PYENV="${SERVICE_HOME}/searx-pyenv"
36SEARX_PYENV="${SERVICE_HOME}/searx-pyenv"
37SEARX_SRC="${SERVICE_HOME}/searx-src"
37SEARX_SRC="${SERVICE_HOME}/searx-src"
38SEARX_SETTINGS_PATH="/etc/searx/settings.yml"
38SEARX_SETTINGS_PATH="/etc/searx/settings.yml"
39+SEARX_SETTINGS_TEMPLATE="${REPO_ROOT}/utils/templates/etc/searx/use_default_settings.yml"
39SEARX_UWSGI_APP="searx.ini"
40SEARX_UWSGI_APP="searx.ini"
40# shellcheck disable=SC2034
41# shellcheck disable=SC2034
41SEARX_UWSGI_SOCKET="/run/uwsgi/app/searx/socket"
42SEARX_UWSGI_SOCKET="/run/uwsgi/app/searx/socket"
@@ -139,7 +140,7 @@ usage() {
139 cat <<EOF
140 cat <<EOF
140usage::
141usage::
141 $(basename "$0") shell
142 $(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]
143 $(basename "$0") update [searx]
144 $(basename "$0") update [searx]
144 $(basename "$0") remove [all|user|pyenv|searx-src]
145 $(basename "$0") remove [all|user|pyenv|searx-src]
145 $(basename "$0") activate [service]
146 $(basename "$0") activate [service]
@@ -413,14 +414,14 @@ install_settings() {
413 if [[ ! -f ${SEARX_SETTINGS_PATH} ]]; then
414 if [[ ! -f ${SEARX_SETTINGS_PATH} ]]; then
414 info_msg "install settings ${REPO_ROOT}/searx/settings.yml"
415 info_msg "install settings ${REPO_ROOT}/searx/settings.yml"
415 info_msg " --> ${SEARX_SETTINGS_PATH}"
416 info_msg " --> ${SEARX_SETTINGS_PATH}"
416− cp "${REPO_ROOT}/searx/settings.yml" "${SEARX_SETTINGS_PATH}"
417+ cp "${SEARX_SETTINGS_TEMPLATE}" "${SEARX_SETTINGS_PATH}"
417 configure_searx
418 configure_searx
418 return
419 return
419 fi
420 fi
420
421
421 rst_para "Diff between origin's setting file (+) and current (-):"
422 rst_para "Diff between origin's setting file (+) and current (-):"
422− echo
423+ echo "${SEARX_SETTINGS_PATH}" "${SEARX_SETTINGS_TEMPLATE}"
423− $DIFF_CMD "${SEARX_SETTINGS_PATH}" "${SEARX_SRC}/searx/settings.yml"
424+ $DIFF_CMD "${SEARX_SETTINGS_PATH}" "${SEARX_SETTINGS_TEMPLATE}"
424
425
425 local action
426 local action
426 choose_one action "What should happen to the settings file? " \
427 choose_one action "What should happen to the settings file? " \
@@ -434,7 +435,7 @@ install_settings() {
434 "use origin settings")
435 "use origin settings")
435 backup_file "${SEARX_SETTINGS_PATH}"
436 backup_file "${SEARX_SETTINGS_PATH}"
436 info_msg "install origin settings"
437 info_msg "install origin settings"
437− cp "${SEARX_SRC}/searx/settings.yml" "${SEARX_SETTINGS_PATH}"
438+ cp "${SEARX_SETTINGS_TEMPLATE}" "${SEARX_SETTINGS_PATH}"
438 ;;
439 ;;
439 "start interactiv shell")
440 "start interactiv shell")
440 backup_file "${SEARX_SETTINGS_PATH}"
441 backup_file "${SEARX_SETTINGS_PATH}"
@@ -442,7 +443,7 @@ install_settings() {
442 sudo -H -i
443 sudo -H -i
443 rst_para 'Diff between new setting file (-) and current (+):'
444 rst_para 'Diff between new setting file (-) and current (+):'
444 echo
445 echo
445− $DIFF_CMD "${SEARX_SRC}/searx/settings.yml" "${SEARX_SETTINGS_PATH}"
446+ $DIFF_CMD "${SEARX_SETTINGS_TEMPLATE}" "${SEARX_SETTINGS_PATH}"
446 wait_key
447 wait_key
447 ;;
448 ;;
448 esac
449 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"