@@ -4,18 +4,27 @@
44Install with nginx
55==================
66
7−.. sidebar:: public HTTP servers
8−
9− On public searx instances use an application firewall (:ref:`filtron
10− <filtron.sh>`).
7+.. _nginx:
8+ https://docs.nginx.com/nginx/admin-guide/
9+.. _nginx server configuration:
10+ https://docs.nginx.com/nginx/admin-guide/web-server/web-server/#setting-up-virtual-servers
11+.. _nginx beginners guide:
12+ http://nginx.org/en/docs/beginners_guide.html
13+.. _Getting Started wiki:
14+ https://www.nginx.com/resources/wiki/start/
1115
1216.. contents:: Contents
1317 :depth: 2
1418 :local:
1519 :backlinks: entry
1620
17−If nginx is not installed (uwsgi will not work with the package
18−nginx-light):
21+
22+The nginx HTTP server
23+=====================
24+
25+If nginx_ is not installed (uwsgi will not work with the package nginx-light)
26+install it now.
27+
1928
2029.. tabs::
2130
@@ -25,87 +34,208 @@ nginx-light):
2534
2635 sudo -H apt-get install nginx
2736
28−Hosted at ``/``
29−===============
37+ .. group-tab:: Arch Linux
3038
31−Create the configuration file ``/etc/nginx/sites-available/searx`` with this
32−content:
39+ .. code-block:: sh
3340
34−.. code:: nginx
41+ sudo -H pacman -S nginx-mainline
42+ sudo -H systemctl enable nginx
43+ sudo -H systemctl start nginx
3544
36− server {
37− listen 80;
38− server_name searx.example.com;
39− root /usr/local/searx/searx;
45+ .. group-tab:: Fedora / RHEL
4046
41− location /static {
42− }
47+ .. code-block:: sh
4348
44− location / {
45− include uwsgi_params;
46− uwsgi_pass unix:/run/uwsgi/app/searx/socket;
47− }
48− }
49+ sudo -H dnf install nginx
50+ sudo -H systemctl enable nginx
51+ sudo -H systemctl start nginx
4952
50−Create a symlink to sites-enabled:
53+Now at http://localhost you should see a *Welcome to nginx!* page, on Fedora you
54+see a *Fedora Webserver - Test Page*. The test page comes from the default
55+`nginx server configuration`_:
5156
52−.. code:: sh
57+.. tabs::
5358
54− sudo -H ln -s /etc/nginx/sites-available/searx /etc/nginx/sites-enabled/searx
59+ .. group-tab:: Ubuntu / debian
5560
56−Restart service:
61+ .. code:: sh
62+
63+ less /etc/nginx/nginx.conf
64+
65+ there is a line including site configurations from:
66+
67+ .. code:: nginx
68+
69+ include /etc/nginx/sites-enabled/*;
70+
71+ .. group-tab:: Arch Linux
72+
73+ .. code-block:: sh
74+
75+ less /etc/nginx/nginx.conf
76+
77+ in there is a configuration section named ``server``:
78+
79+ .. code-block:: nginx
80+
81+ server {
82+ listen 80;
83+ server_name localhost;
84+ # ...
85+ }
86+
87+ .. group-tab:: Fedora / RHEL
88+
89+ .. code-block:: sh
90+
91+ less /etc/nginx/nginx.conf
92+
93+ there is a line including site configurations from:
94+
95+ .. code:: nginx
96+
97+ include /etc/nginx/conf.d/*.conf;
98+
99+.. _nginx searx site:
100+
101+A searx site
102+============
103+
104+.. sidebar:: public to the internet?
105+
106+ If your searx instance is public, stop here and first install :ref:`filtron
107+ reverse proxy <filtron.sh>` and :ref:`result proxy morty <morty.sh>`, see
108+ :ref:`installation scripts`.
109+
110+Now you have to create a configuration for the searx site. If nginx_ is new to
111+you, the `nginx beginners guide`_ is a good starting point and the `Getting
112+Started wiki`_ is always a good resource *to keep in the pocket*.
57113
58114.. tabs::
59115
60116 .. group-tab:: Ubuntu / debian
61117
118+ Create configuration at ``/etc/nginx/sites-available/searx`` and place a
119+ symlink to sites-enabled:
120+
62121 .. code:: sh
63122
64− sudo -H systemctl restart nginx
65− sudo -H systemctl restart uwsgi
123+ sudo -H ln -s /etc/nginx/sites-available/searx /etc/nginx/sites-enabled/searx
66124
67−from subdirectory URL (``/searx``)
68−==================================
125+ .. group-tab:: Arch Linux
69126
70−Add this configuration in the server config file
71−``/etc/nginx/sites-enabled/default``:
127+ In the ``/etc/nginx/nginx.conf`` file, replace the configuration section
128+ named ``server``.
72129
73−.. code:: nginx
130+ .. group-tab:: Fedora / RHEL
74131
75− location /searx/static {
76− alias /usr/local/searx/searx/static;
77− }
132+ Create configuration at ``/etc/nginx/conf.d/searx`` and place a
133+ symlink to sites-enabled:
78134
79− location /searx {
80− uwsgi_param SCRIPT_NAME /searx;
81− include uwsgi_params;
82− uwsgi_pass unix:/run/uwsgi/app/searx/socket;
83− }
135+.. tabs::
84136
85137
86−**OR** using reverse proxy (Please, note that reverse proxy advised to be used
87−in case of single-user or low-traffic instances.)
138+ .. group-tab:: filtron at ``/`` & ``/morty``
88139
89−.. code:: nginx
140+ Use this setup, if your instance is public to the internet:
90141
91− location /searx/static {
92− alias /usr/local/searx/searx/static;
93− }
142+ .. code:: nginx
94143
95− location /searx {
96− proxy_pass http://127.0.0.1:8888;
97− proxy_set_header Host $host;
98− proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
99− proxy_set_header X-Scheme $scheme;
100− proxy_set_header X-Script-Name /searx;
101− proxy_buffering off;
102− }
144+ location / {
145+ proxy_set_header Host $http_host;
146+ proxy_set_header X-Real-IP $remote_addr;
147+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
148+ proxy_set_header X-Scheme $scheme;
149+ proxy_pass http://127.0.0.1:4004/;
150+ }
103151
104−Enable ``base_url`` in ``searx/settings.yml``
152+ .. code:: nginx
105153
106−.. code:: yaml
154+ location /morty {
155+ proxy_set_header Host $http_host;
156+ proxy_set_header X-Real-IP $remote_addr;
157+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
158+ proxy_set_header X-Scheme $scheme;
159+ proxy_pass http://127.0.0.1:3000/;
160+ }
161+
162+ For a fully result proxification add :ref:`morty's <searx_morty>` public
163+ URL to your :origin:`searx/settings.yml`:
164+
165+ .. code:: yaml
166+
167+ result_proxy:
168+ # replace searx.example.com with your server's public name
169+ url : http://searx.example.com/
170+
171+
172+ .. group-tab:: searx at ``/``
173+
174+ Use this setup only, if your instance is **NOT** public to the internet:
175+
176+ .. code:: nginx
177+
178+ server {
179+ listen 80;
180+ listen [::]:80;
181+
182+ # replace searx.example.com with your server's public name
183+ server_name searx.example.com;
184+
185+ root /usr/local/searx/searx;
186+
187+ location /static {
188+ }
189+
190+ location / {
191+ include uwsgi_params;
192+ uwsgi_pass unix:/run/uwsgi/app/searx/socket;
193+ }
194+ }
195+
196+ .. group-tab:: searx at ``/searx``
197+
198+ Use this setup only, if your instance is **NOT** public to the internet:
199+
200+ .. code:: nginx
201+
202+ location /searx/static {
203+ alias /usr/local/searx/searx/static;
204+ }
205+
206+ location /searx {
207+ uwsgi_param SCRIPT_NAME /searx;
208+ include uwsgi_params;
209+ uwsgi_pass unix:/run/uwsgi/app/searx/socket;
210+ }
211+
212+
213+ **OR** using reverse proxy. Please, note that reverse proxy advised to be
214+ used in case of single-user or low-traffic instances.
215+
216+ .. code:: nginx
217+
218+ location /searx/static {
219+ alias /usr/local/searx/searx/static;
220+ }
221+
222+ location /searx {
223+ proxy_pass http://127.0.0.1:8888;
224+ proxy_set_header Host $host;
225+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
226+ proxy_set_header X-Scheme $scheme;
227+ proxy_set_header X-Script-Name /searx;
228+ proxy_buffering off;
229+ }
230+
231+ Enable ``base_url`` in :origin:`searx/settings.yml`
232+
233+ .. code:: yaml
234+
235+ server:
236+ # replace searx.example.com with your server's public name
237+ base_url : http://searx.example.com/searx/
107238
108− base_url : http://your.domain.tld/searx/
109239
110240Restart service:
111241
@@ -118,24 +248,31 @@ Restart service:
118248 sudo -H systemctl restart nginx
119249 sudo -H systemctl restart uwsgi
120250
251+ .. group-tab:: Arch Linux
121252
122−disable logs
123−============
253+ .. code:: sh
124254
125−For better privacy you can disable nginx logs about searx. How to proceed:
126−below ``uwsgi_pass`` in ``/etc/nginx/sites-available/default`` add:
255+ sudo -H systemctl restart nginx
256+ sudo -H systemctl restart uwsgi
127257
128−.. code:: nginx
258+ .. group-tab:: Fedora
129259
130− access_log /dev/null;
131− error_log /dev/null;
260+ .. code:: sh
132261
133−Restart service:
262+ sudo -H systemctl restart nginx
263+ sudo -H systemctl restart uwsgi
134264
135−.. tabs::
136265
137− .. group-tab:: Ubuntu / debian
266+Disable logs
267+============
138268
139− .. code:: sh
269+For better privacy you can disable nginx logs in ``/etc/nginx/nginx.conf``.
140270
141− sudo -H systemctl restart nginx
271+.. code:: nginx
272+
273+ http {
274+ # ...
275+ access_log /dev/null;
276+ error_log /dev/null;
277+ # ...
278+ }