on 2dff388 help sign in
searx/docs/admin/installation-apache.rst
514 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`.
183To pass the HTTP HOST header
184With ProxyPreserveHost_ the incoming Host HTTP request header is passed to the
185proxied host.
187.. tabs::
189 .. group-tab:: Ubuntu / debian
191 In the Apache setup, enable headers and proxy modules:
193 .. code:: sh
195 sudo -H a2enmod headers
196 sudo -H a2enmod proxy
197 sudo -H a2enmod proxy_http
199 In :ref:`The Debian Layout` you create a ``searx.conf`` with the
200 ``<Location /searx >`` directive and save this file in the *sites
201 available* folder at ``/etc/apache2/sites-available``. To enable the
202 ``searx.conf`` use :man:`a2ensite`:
204 .. code:: sh
206 sudo -H a2ensite searx.conf
208 .. group-tab:: Arch Linux
210 In the ``/etc/httpd/conf/httpd.conf`` file, activate headers and proxy
211 modules (LoadModule_):
213 .. code:: apache
215 FIXME needs test
217 LoadModule headers_module modules/mod_headers.so
218 LoadModule proxy_module modules/mod_proxy.so
219 LoadModule proxy_http_module modules/mod_proxy_http.so
221 .. group-tab:: Fedora / RHEL
223 In the ``/etc/httpd/conf/httpd.conf`` file, activate headers and proxy
224 modules (LoadModule_):
226 .. code:: apache
228 FIXME needs test
230 LoadModule headers_module modules/mod_headers.so
231 LoadModule proxy_module modules/mod_proxy.so
232 LoadModule proxy_http_module modules/mod_proxy_http.so
234.. tabs::
236 .. group-tab:: searx via filtron plus morty
238 Use this setup, if your instance is public to the internet, compare
239 figure: :ref:`architecture <arch public>` and :ref:`installation scripts`.
241 1. Configure a reverse proxy for :ref:`filtron <filtron.sh>`, listening on
242 *localhost 4004* (:ref:`filtron route request`):
244 .. code:: apache
246 <Location /searx >
248 # SetEnvIf Request_URI "/searx" dontlog
249 # CustomLog /dev/null combined env=dontlog
251 Require all granted
253 Order deny,allow
254 Deny from all
255 #Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
256 Allow from all
258 ProxyPreserveHost On
259 ProxyPass http://127.0.0.1:4004
260 RequestHeader set X-Script-Name /searx
262 </Location>
264 2. Configure reverse proxy for :ref:`morty <searx morty>`, listening on
265 *localhost 3000*
267 .. code:: apache
269 ProxyPreserveHost On
271 <Location /morty >
273 # SetEnvIf Request_URI "/morty" dontlog
274 # CustomLog /dev/null combined env=dontlog
276 Require all granted
278 Order deny,allow
279 Deny from all
280 #Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
281 Allow from all
283 ProxyPass http://127.0.0.1:3000
284 RequestHeader set X-Script-Name /morty
286 </Location>
288 Note that reverse proxy advised to be used in case of single-user or
289 low-traffic instances. For a fully result proxification add :ref:`morty's
290 <searx morty>` **public 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
298 server:
299 image_proxy : True
301uWSGI support
302=============
304Be warned, with this setup, your instance isn't :ref:`protected <searx
305filtron>`, nevertheless it is good enough for intranet usage. In modern Linux
306distributions, the `mod_proxy_uwsgi`_ is compiled into the *normal* apache
307package and you need to install only the :ref:`uWSGI <searx uwsgi>` package:
309.. tabs::
311 .. group-tab:: Ubuntu / debian
313 .. code:: sh
315 sudo -H apt-get install uwsgi
317 # Ubuntu =< 18.04
318 sudo -H apt-get install libapache2-mod-proxy-uwsgi
320 .. group-tab:: Arch Linux
322 .. code:: sh
324 sudo -H pacman -S uwsgi
326 .. group-tab:: Fedora / RHEL
328 .. code:: sh
330 sudo -H dnf install uwsgi
332The next example shows a configuration using the `uWSGI Apache support`_ via
333unix sockets and `mod_proxy_uwsgi`_.
335For socket communication, you have to activate ``socket =
336/run/uwsgi/app/searx/socket`` and comment out the ``http = 127.0.0.1:8888``
337configuration in your :ref:`uwsgi ini file <uwsgi configuration>`. If not
338already exists, create a folder for the unix sockets, which can be used by the
339searx account (see :ref:`create searx user`):
341.. code:: bash
343 sudo -H mkdir -p /run/uwsgi/app/searx/
344 sudo -H chown -R searx:searx /run/uwsgi/app/searx/
346If the server is public; to limit access to your intranet replace ``Allow from
347all`` directive and replace ``192.168.0.0/16`` with your subnet IP/class.
349.. tabs::
351 .. group-tab:: Ubuntu / debian
353 .. code:: apache
355 LoadModule headers_module /usr/lib/apache2/mod_headers.so
356 LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
357 LoadModule proxy_uwsgi_module /usr/lib/apache2/modules/mod_proxy_uwsgi.so
359 # SetEnvIf Request_URI /searx dontlog
360 # CustomLog /dev/null combined env=dontlog
362 <Location /searx>
364 Require all granted
365 Order deny,allow
366 Deny from all
367 # Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
368 Allow from all
370 ProxyPreserveHost On
371 ProxyPass unix:/run/uwsgi/app/searx/socket|uwsgi://uwsgi-uds-searx/
373 </Location>
375 .. group-tab:: Arch Linux
377 .. code:: apache
379 FIXME needs test
381 LoadModule proxy_module modules/mod_proxy.so
382 LoadModule proxy_uwsgi_module modules/mod_proxy_uwsgi.so
384 # SetEnvIf Request_URI /searx dontlog
385 # CustomLog /dev/null combined env=dontlog
387 <Location /searx>
389 Require all granted
390 Order deny,allow
391 Deny from all
392 # Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
393 Allow from all
395 ProxyPreserveHost On
396 ProxyPass unix:/run/uwsgi/app/searx/socket|uwsgi://uwsgi-uds-searx/
398 </Location>
400 .. group-tab:: Fedora / RHEL
402 .. code:: apache
404 FIXME needs test
406 LoadModule proxy_module modules/mod_proxy.so
407 LoadModule proxy_uwsgi_module modules/mod_proxy_uwsgi.so
408 <IfModule proxy_uwsgi_module>
410 # SetEnvIf Request_URI /searx dontlog
411 # CustomLog /dev/null combined env=dontlog
413 <Location /searx>
415 Require all granted
416 Order deny,allow
417 Deny from all
418 # Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
419 Allow from all
421 ProxyPreserveHost On
422 ProxyPass unix:/run/uwsgi/app/searx/socket|uwsgi://uwsgi-uds-searx/
424 </Location>
426 </IfModule>
428 .. group-tab:: old mod_wsgi
430 We show this only for historical reasons, DON'T USE `mod_uwsgi
431 <https://uwsgi-docs.readthedocs.io/en/latest/Apache.html#mod-uwsgi>`_.
432 ANYMORE!
434 .. code:: apache
436 <IfModule mod_uwsgi.c>
438 # SetEnvIf Request_URI "/searx" dontlog
439 # CustomLog /dev/null combined env=dontlog
441 <Location /searx >
443 Require all granted
445 Options FollowSymLinks Indexes
446 SetHandler uwsgi-handler
447 uWSGISocket /run/uwsgi/app/searx/socket
449 Order deny,allow
450 Deny from all
451 # Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
452 Allow from all
454 </Location>
456 </IfModule>
458.. _restart apache:
460Restart service
461===============
463.. tabs::
465 .. group-tab:: Ubuntu / debian
467 .. code:: sh
469 sudo -H systemctl restart apache2
470 sudo -H service uwsgi restart searx
472 .. group-tab:: Arch Linux
474 .. code:: sh
476 sudo -H systemctl restart httpd
477 sudo -H systemctl restart uwsgi@searx
479 .. group-tab:: Fedora / RHEL
481 .. code:: sh
483 sudo -H systemctl restart httpd
484 sudo -H touch /etc/uwsgi.d/searx.ini
487disable logs
488============
490For better privacy you can disable Apache logs. In the examples above activate
491one of the lines and `restart apache`_::
494 # SetEnvIf Request_URI "/searx" dontlog
495 # CustomLog /dev/null combined env=dontlog
497The ``CustomLog`` directive disable logs for the whole (virtual) server, use it
498when the URL of the service does not have a path component (``/searx``) / is
499located at root (``/``).
501.. _The Debian Layout:
503The Debian Layout
504=================
506Be aware that the Debian layout is quite different from the standard Apache
507configuration. For details look at the README.Debian_
508(``/usr/share/doc/apache2/README.Debian.gz``). Some commands you should know on
509Debian:
511* :man:`apache2ctl`: Apache HTTP server control interface
512* :man:`a2enmod`, :man:`a2dismod`: switch on/off modules
513* :man:`a2enconf`, :man:`a2disconf`: switch on/off configurations
514* :man:`a2ensite`, :man:`a2dissite`: switch on/off sites