on v1.0.0 help sign in
searx/docs/admin/installation-apache.rst
515 lines 14 kB history raw
1.. _installation apache:
3===================
4Install with apache
5===================
7.. _Apache: https://httpd.apache.org/
8.. _Apache Debian:
9 https://cwiki.apache.org/confluence/display/HTTPD/DistrosDefaultLayout#DistrosDefaultLayout-Debian,Ubuntu(Apachehttpd2.x):
10.. _README.Debian:
11 https://salsa.debian.org/apache-team/apache2/raw/master/debian/apache2.README.Debian
12.. _Apache Arch Linux:
13 https://wiki.archlinux.org/index.php/Apache_HTTP_Server
14.. _Apache Fedora:
15 https://docs.fedoraproject.org/en-US/quick-docs/getting-started-with-apache-http-server/index.html
16.. _Apache directives:
17 https://httpd.apache.org/docs/trunk/mod/directives.html
18.. _Getting Started:
19 https://httpd.apache.org/docs/current/en/getting-started.html
20.. _Terms Used to Describe Directives:
21 https://httpd.apache.org/docs/current/en/mod/directive-dict.html
22.. _Configuration Files:
23 https://httpd.apache.org/docs/current/en/configuring.html
24.. _ProxyPreserveHost: https://httpd.apache.org/docs/trunk/mod/mod_proxy.html#proxypreservehost
25.. _LoadModule:
26 https://httpd.apache.org/docs/2.4/mod/mod_so.html#loadmodule
27.. _DocumentRoot:
28 https://httpd.apache.org/docs/trunk/mod/core.html#documentroot
29.. _Location:
30 https://httpd.apache.org/docs/trunk/mod/core.html#location
31.. _uWSGI Apache support:
32 https://uwsgi-docs.readthedocs.io/en/latest/Apache.html
33.. _mod_proxy_uwsgi:
34 https://uwsgi-docs.readthedocs.io/en/latest/Apache.html#mod-proxy-uwsgi
36.. sidebar:: further read
38 - `Apache Arch Linux`_
39 - `Apache Debian`_ and `README.Debian`_
40 - `Apache Fedora`_
41 - `Apache directives`_
43.. contents:: Contents
44 :depth: 2
45 :local:
46 :backlinks: entry
48----
50**Install** :ref:`apache searx site` using :ref:`filtron.sh <filtron.sh overview>`
52.. code:: bash
54 $ sudo -H ./utils/filtron.sh apache install
56**Install** :ref:`apache searx site` using :ref:`morty.sh <morty.sh overview>`
58.. code:: bash
60 $ sudo -H ./utils/morty.sh apache install
62----
64The apache HTTP server
65======================
67If Apache_ is not installed, install it now. If apache_ is new to you, the
68`Getting Started`_, `Configuration Files`_ and `Terms Used to Describe
69Directives`_ documentation gives first orientation. There is also a list of
70`Apache directives`_ *to keep in the pocket*.
72.. tabs::
74 .. group-tab:: Ubuntu / debian
76 .. code:: sh
78 sudo -H apt-get install apache2
80 .. group-tab:: Arch Linux
82 .. code:: sh
84 sudo -H pacman -S apache
85 sudo -H systemctl enable httpd
86 sudo -H systemctl start http
88 .. group-tab:: Fedora / RHEL
90 .. code:: sh
92 sudo -H dnf install httpd
93 sudo -H systemctl enable httpd
94 sudo -H systemctl start httpd
96Now at http://localhost you should see any kind of *Welcome* or *Test* page.
97How this default intro site is configured, depends on the linux distribution
98(compare `Apache directives`_).
100.. tabs::
102 .. group-tab:: Ubuntu / debian
104 .. code:: sh
106 less /etc/apache2/sites-enabled/000-default.conf
108 In this file, there is a line setting the `DocumentRoot`_ directive:
110 .. code:: apache
112 DocumentRoot /var/www/html
114 And the *welcome* page is the HTML file at ``/var/www/html/index.html``.
116 .. group-tab:: Arch Linux
118 .. code:: sh
120 less /etc/httpd/conf/httpd.conf
122 In this file, there is a line setting the `DocumentRoot`_ directive:
124 .. code:: apache
126 DocumentRoot "/srv/http"
127 <Directory "/srv/http">
128 Options Indexes FollowSymLinks
129 AllowOverride None
130 Require all granted
131 </Directory>
133 The *welcome* page of Arch Linux is a page showing directory located at
134 ``DocumentRoot``. This is *directory* page is generated by the Module
135 `mod_autoindex <https://httpd.apache.org/docs/2.4/mod/mod_autoindex.html>`_:
137 .. code:: apache
139 LoadModule autoindex_module modules/mod_autoindex.so
140 ...
141 Include conf/extra/httpd-autoindex.conf
143 .. group-tab:: Fedora / RHEL
145 .. code:: sh
147 less /etc/httpd/conf/httpd.conf
149 In this file, there is a line setting the ``DocumentRoot`` directive:
151 .. code:: apache
153 DocumentRoot "/var/www/html"
154 ...
155 <Directory "/var/www">
156 AllowOverride None
157 # Allow open access:
158 Require all granted
159 </Directory>
161 On fresh installations, the ``/var/www`` is empty and the *default
162 welcome page* is shown, the configuration is located at::
164 less /etc/httpd/conf.d/welcome.conf
166.. _apache searx site:
168Apache Reverse Proxy
169====================
171.. sidebar:: public to the internet?
173 If your searx instance is public, stop here and first install :ref:`filtron
174 reverse proxy <filtron.sh>` and :ref:`result proxy morty <morty.sh>`, see
175 :ref:`installation scripts`. If already done, follow setup: *searx via
176 filtron plus morty*.
178To setup a Apache revers proxy you have to enable the *headers* and *proxy*
179modules and create a `Location`_ configuration for the searx site. In most
180distributions you have to un-comment the lines in the main configuration file,
181except in :ref:`The Debian Layout`.
183.. tabs::
185 .. group-tab:: Ubuntu / debian
187 In the Apache setup, enable headers and proxy modules:
189 .. code:: sh
191 sudo -H a2enmod headers
192 sudo -H a2enmod proxy
193 sudo -H a2enmod proxy_http
195 In :ref:`The Debian Layout` you create a ``searx.conf`` with the
196 ``<Location /searx >`` directive and save this file in the *sites
197 available* folder at ``/etc/apache2/sites-available``. To enable the
198 ``searx.conf`` use :man:`a2ensite`:
200 .. code:: sh
202 sudo -H a2ensite searx.conf
204 .. group-tab:: Arch Linux
206 In the ``/etc/httpd/conf/httpd.conf`` file, activate headers and proxy
207 modules (LoadModule_):
209 .. code:: apache
211 FIXME needs test
213 LoadModule headers_module modules/mod_headers.so
214 LoadModule proxy_module modules/mod_proxy.so
215 LoadModule proxy_http_module modules/mod_proxy_http.so
217 .. group-tab:: Fedora / RHEL
219 In the ``/etc/httpd/conf/httpd.conf`` file, activate headers and proxy
220 modules (LoadModule_):
222 .. code:: apache
224 FIXME needs test
226 LoadModule headers_module modules/mod_headers.so
227 LoadModule proxy_module modules/mod_proxy.so
228 LoadModule proxy_http_module modules/mod_proxy_http.so
230With ProxyPreserveHost_ the incoming Host HTTP request header is passed to the
231proxied host.
233.. _apache searx via filtron plus morty:
235.. tabs::
237 .. group-tab:: searx via filtron plus morty
239 Use this setup, if your instance is public to the internet, compare
240 figure: :ref:`architecture <arch public>` and :ref:`installation scripts`.
242 1. Configure a reverse proxy for :ref:`filtron <filtron.sh>`, listening on
243 *localhost 4004* (:ref:`filtron route request`):
245 .. code:: apache
247 <Location /searx >
249 # SetEnvIf Request_URI "/searx" dontlog
250 # CustomLog /dev/null combined env=dontlog
252 Require all granted
254 Order deny,allow
255 Deny from all
256 #Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
257 Allow from all
259 ProxyPreserveHost On
260 ProxyPass http://127.0.0.1:4004
261 RequestHeader set X-Script-Name /searx
263 </Location>
265 2. Configure reverse proxy for :ref:`morty <searx morty>`, listening on
266 *localhost 3000*
268 .. code:: apache
270 ProxyPreserveHost On
272 <Location /morty >
274 # SetEnvIf Request_URI "/morty" dontlog
275 # CustomLog /dev/null combined env=dontlog
277 Require all granted
279 Order deny,allow
280 Deny from all
281 #Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
282 Allow from all
284 ProxyPass http://127.0.0.1:3000
285 RequestHeader set X-Script-Name /morty
287 </Location>
289 For a fully result proxification add :ref:`morty's <searx morty>` **public
290 URL** to your :origin:`searx/settings.yml`:
292 .. code:: yaml
294 result_proxy:
295 # replace example.org with your server's public name
296 url : https://example.org/morty
297 key : !!binary "insert_your_morty_proxy_key_here"
299 server:
300 image_proxy : True
302uWSGI support
303=============
305Be warned, with this setup, your instance isn't :ref:`protected <searx
306filtron>`, nevertheless it is good enough for intranet usage. In modern Linux
307distributions, the `mod_proxy_uwsgi`_ is compiled into the *normal* apache
308package and you need to install only the :ref:`uWSGI <searx uwsgi>` package:
310.. tabs::
312 .. group-tab:: Ubuntu / debian
314 .. code:: sh
316 sudo -H apt-get install uwsgi
318 # Ubuntu =< 18.04
319 sudo -H apt-get install libapache2-mod-proxy-uwsgi
321 .. group-tab:: Arch Linux
323 .. code:: sh
325 sudo -H pacman -S uwsgi
327 .. group-tab:: Fedora / RHEL
329 .. code:: sh
331 sudo -H dnf install uwsgi
333The next example shows a configuration using the `uWSGI Apache support`_ via
334unix sockets and `mod_proxy_uwsgi`_.
336For socket communication, you have to activate ``socket =
337/run/uwsgi/app/searx/socket`` and comment out the ``http = 127.0.0.1:8888``
338configuration in your :ref:`uwsgi ini file <uwsgi configuration>`. If not
339already exists, create a folder for the unix sockets, which can be used by the
340searx account (see :ref:`create searx user`):
342.. code:: bash
344 sudo -H mkdir -p /run/uwsgi/app/searx/
345 sudo -H chown -R searx:searx /run/uwsgi/app/searx/
347If the server is public; to limit access to your intranet replace ``Allow from
348all`` directive and replace ``192.168.0.0/16`` with your subnet IP/class.
350.. tabs::
352 .. group-tab:: Ubuntu / debian
354 .. code:: apache
356 LoadModule headers_module /usr/lib/apache2/mod_headers.so
357 LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
358 LoadModule proxy_uwsgi_module /usr/lib/apache2/modules/mod_proxy_uwsgi.so
360 # SetEnvIf Request_URI /searx dontlog
361 # CustomLog /dev/null combined env=dontlog
363 <Location /searx>
365 Require all granted
366 Order deny,allow
367 Deny from all
368 # Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
369 Allow from all
371 ProxyPreserveHost On
372 ProxyPass unix:/run/uwsgi/app/searx/socket|uwsgi://uwsgi-uds-searx/
374 </Location>
376 .. group-tab:: Arch Linux
378 .. code:: apache
380 FIXME needs test
382 LoadModule proxy_module modules/mod_proxy.so
383 LoadModule proxy_uwsgi_module modules/mod_proxy_uwsgi.so
385 # SetEnvIf Request_URI /searx dontlog
386 # CustomLog /dev/null combined env=dontlog
388 <Location /searx>
390 Require all granted
391 Order deny,allow
392 Deny from all
393 # Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
394 Allow from all
396 ProxyPreserveHost On
397 ProxyPass unix:/run/uwsgi/app/searx/socket|uwsgi://uwsgi-uds-searx/
399 </Location>
401 .. group-tab:: Fedora / RHEL
403 .. code:: apache
405 FIXME needs test
407 LoadModule proxy_module modules/mod_proxy.so
408 LoadModule proxy_uwsgi_module modules/mod_proxy_uwsgi.so
409 <IfModule proxy_uwsgi_module>
411 # SetEnvIf Request_URI /searx dontlog
412 # CustomLog /dev/null combined env=dontlog
414 <Location /searx>
416 Require all granted
417 Order deny,allow
418 Deny from all
419 # Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
420 Allow from all
422 ProxyPreserveHost On
423 ProxyPass unix:/run/uwsgi/app/searx/socket|uwsgi://uwsgi-uds-searx/
425 </Location>
427 </IfModule>
429 .. group-tab:: old mod_wsgi
431 We show this only for historical reasons, DON'T USE `mod_uwsgi
432 <https://uwsgi-docs.readthedocs.io/en/latest/Apache.html#mod-uwsgi>`_.
433 ANYMORE!
435 .. code:: apache
437 <IfModule mod_uwsgi.c>
439 # SetEnvIf Request_URI "/searx" dontlog
440 # CustomLog /dev/null combined env=dontlog
442 <Location /searx >
444 Require all granted
446 Options FollowSymLinks Indexes
447 SetHandler uwsgi-handler
448 uWSGISocket /run/uwsgi/app/searx/socket
450 Order deny,allow
451 Deny from all
452 # Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
453 Allow from all
455 </Location>
457 </IfModule>
459.. _restart apache:
461Restart service
462===============
464.. tabs::
466 .. group-tab:: Ubuntu / debian
468 .. code:: sh
470 sudo -H systemctl restart apache2
471 sudo -H service uwsgi restart searx
473 .. group-tab:: Arch Linux
475 .. code:: sh
477 sudo -H systemctl restart httpd
478 sudo -H systemctl restart uwsgi@searx
480 .. group-tab:: Fedora / RHEL
482 .. code:: sh
484 sudo -H systemctl restart httpd
485 sudo -H touch /etc/uwsgi.d/searx.ini
488disable logs
489============
491For better privacy you can disable Apache logs. In the examples above activate
492one of the lines and `restart apache`_::
495 # SetEnvIf Request_URI "/searx" dontlog
496 # CustomLog /dev/null combined env=dontlog
498The ``CustomLog`` directive disable logs for the whole (virtual) server, use it
499when the URL of the service does not have a path component (``/searx``) / is
500located at root (``/``).
502.. _The Debian Layout:
504The Debian Layout
505=================
507Be aware that the Debian layout is quite different from the standard Apache
508configuration. For details look at the README.Debian_
509(``/usr/share/doc/apache2/README.Debian.gz``). Some commands you should know on
510Debian:
512* :man:`apache2ctl`: Apache HTTP server control interface
513* :man:`a2enmod`, :man:`a2dismod`: switch on/off modules
514* :man:`a2enconf`, :man:`a2disconf`: switch on/off configurations
515* :man:`a2ensite`, :man:`a2dissite`: switch on/off sites