on master help sign in
Fix Nginx subdir URL install docs which allowed download of settings.yml

Closes: #1617 There is an issue with the setup example in https://asciimoo.github.io/searx/dev/install/installation.html#installation for subdirectory URL deployments: ```nginx root /usr/local/searx; location = /searx { rewrite ^ /searx/; } try_files $uri @searx; } location @searx { uwsgi_param SCRIPT_NAME /searx; include uwsgi_params; uwsgi_modifier1 30; uwsgi_pass unix:/run/uwsgi/app/searx/socket; } ``` `try_files` causes Nginx to search for files in the server root first. If it matches a file, it is returned. Only if no file matched, the request is passed to uwsgi. The worst consequence I can think of is that `settings.yml` can be downloaded without authentication (where secrets and configuration details are stored). To fix this, I propose: ```nginx location = /searx { rewrite ^ /searx/; } location /searx/static { } location /searx { uwsgi_param SCRIPT_NAME /searx; include uwsgi_params; uwsgi_pass unix:/run/uwsgi/app/searx/socket; } ``` And add ``` route-run = fixpathinfo: ``` to `/etc/uwsgi/apps-available/searx.ini` because `uwsgi_modifier1 30` is apparently deprecated. Ref: https://uwsgi-docs.readthedocs.io/en/latest/Changelog-2.0.11.html#fixpathinfo-routing-action I assume this issue exists because some uwsgi upstream docs also use the `try_files` construct (at least I have seen this somewhere in the docs or somewhere else on the Internet but cannot find it right now again). https://uwsgi-docs.readthedocs.io/en/latest/Nginx.html#hosting-multiple-apps-in-the-same-process-aka-managing-script-name-and-path-info also warns about this: > If used incorrectly a configuration like this may cause security problems. For your sanity’s sake, double-triple-quadruple check that your application files, configuration files and any other sensitive files are outside of the root of the static files.

commita1d9c81915b169272cf26139445f3e08e9b689b9 authorRobin Schneider <ypid@riseup.net> dateTue 31 Dec 2019, 14:24 (7 years ago) parent754a10c
1 file changed+10−6
docs/admin/installation.rst+10−6
docs/admin/installation.rst+10−6
@@ -114,6 +114,9 @@ content:
114114 # Module to import
115115 module = searx.webapp
116116
117+ # Support running the module from a webserver subdirectory.
118+ route-run = fixpathinfo:
119+
117120 # Virtualenv and python path
118121 virtualenv = /usr/local/searx/searx-ve/
119122 pythonpath = /usr/local/searx/
@@ -180,14 +183,16 @@ Add this configuration in the server config file
180183
181184.. code:: nginx
182185
183− location = /searx { rewrite ^ /searx/; }
184− location /searx {
185− try_files $uri @searx;
186+ location = /searx {
187+ rewrite ^ /searx/;
188+ }
189+
190+ location /searx/static {
186191 }
187− location @searx {
192+
193+ location /searx {
188194 uwsgi_param SCRIPT_NAME /searx;
189195 include uwsgi_params;
190− uwsgi_modifier1 30;
191196 uwsgi_pass unix:/run/uwsgi/app/searx/socket;
192197 }
193198
@@ -338,4 +343,3 @@ References
338343
339344* How to: `Setup searx in a couple of hours with a free SSL certificate
340345 <https://www.reddit.com/r/privacytoolsIO/comments/366kvn/how_to_setup_your_own_privacy_respecting_search/>`__
341−