@@ -4,19 +4,303 @@
4Install with apache
4Install with apache
5===================
5===================
7−.. sidebar:: public to the internet?
7+.. _Apache: https://httpd.apache.org/
9− If your searx instance is public, stop here and first install :ref:`filtron
9+ https://cwiki.apache.org/confluence/display/HTTPD/DistrosDefaultLayout#DistrosDefaultLayout-Debian,Ubuntu(Apachehttpd2.x):
10− reverse proxy <filtron.sh>` and :ref:`result proxy morty <morty.sh>`, see
10+.. _README.Debian:
11− :ref:`installation scripts`.
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
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
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
26+ https://httpd.apache.org/docs/2.4/mod/mod_so.html#loadmodule
28+ https://httpd.apache.org/docs/trunk/mod/core.html#documentroot
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
34+ https://uwsgi-docs.readthedocs.io/en/latest/Apache.html#mod-proxy-uwsgi
36+ https://uwsgi-docs.readthedocs.io/en/latest/Apache.html#mod-proxy-uwsgi
38+.. sidebar:: further read
40+ - `Apache Arch Linux`_
41+ - `Apache Debian`_ and `README.Debian`_
43+ - `Apache directives`_
13.. contents:: Contents
45.. contents:: Contents
16 :backlinks: entry
48 :backlinks: entry
18−Add wsgi mod
50+The apache HTTP server
19−============
51+======================
53+If Apache_ is not installed, install it now. If apache_ is new to you, the
54+`Getting Started`_, `Configuration Files`_ and `Terms Used to Describe
55+Directives`_ documentation gives first orientation. There is also a list of
56+`Apache directives`_ *to keep in the pocket*.
60+ .. group-tab:: Ubuntu / debian
64+ sudo -H apt-get install apache2
66+ .. group-tab:: Arch Linux
70+ sudo -H pacman -S apache
71+ sudo -H systemctl enable httpd
72+ sudo -H systemctl start http
74+ .. group-tab:: Fedora / RHEL
78+ sudo -H dnf install httpd
79+ sudo -H systemctl enable httpd
80+ sudo -H systemctl start httpd
82+Now at http://localhost you should see any kind of *Welcome* or *Test* page.
83+How this default intro site is configured, depends on the linux distribution
84+(compare `Apache directives`_).
88+ .. group-tab:: Ubuntu / debian
92+ less /etc/apache2/sites-enabled/000-default.conf
94+ In this file, there is a line setting the `DocumentRoot`_ directive:
98+ DocumentRoot /var/www/html
100+ And the *welcome* page is the HTML file at ``/var/www/html/index.html``.
102+ .. group-tab:: Arch Linux
106+ less /etc/httpd/conf/httpd.conf
108+ In this file, there is a line setting the `DocumentRoot`_ directive:
112+ DocumentRoot "/srv/http"
113+ <Directory "/srv/http">
114+ Options Indexes FollowSymLinks
119+ The *welcome* page of Arch Linux is a page showing directory located at
120+ ``DocumentRoot``. This is *directory* page is generated by the Module
121+ `mod_autoindex <https://httpd.apache.org/docs/2.4/mod/mod_autoindex.html>`_:
125+ LoadModule autoindex_module modules/mod_autoindex.so
127+ Include conf/extra/httpd-autoindex.conf
129+ .. group-tab:: Fedora / RHEL
133+ less /etc/httpd/conf/httpd.conf
135+ In this file, there is a line setting the ``DocumentRoot`` directive:
139+ DocumentRoot "/var/www/html"
141+ <Directory "/var/www">
143+ # Allow open access:
147+ On fresh installations, the ``/var/www`` is empty and the *default
148+ welcome page* is shown, the configuration is located at::
150+ less /etc/httpd/conf.d/welcome.conf
152+.. _The Debian Layout:
157+Be aware that the Debian layout is quite different from the standard Apache
158+configuration. For details look at the README.Debian_
159+(``/usr/share/doc/apache2/README.Debian.gz``). Some commands you should know on
162+* :man:`apache2ctl`: Apache HTTP server control interface
163+* :man:`a2enmod`, :man:`a2dismod`: switch on/off modules
164+* :man:`a2enconf`, :man:`a2disconf`: switch on/off configurations
165+* :man:`a2ensite`, :man:`a2dissite`: switch on/off sites
168+.. _apache searx site:
173+.. sidebar:: public to the internet?
175+ If your searx instance is public, stop here and first install :ref:`filtron
176+ reverse proxy <filtron.sh>` and :ref:`result proxy morty <morty.sh>`, see
177+ :ref:`installation scripts`. If already done, follow setup: *searx via
178+ filtron plus morty*.
180+To setup a Apache revers proxy you have to enable the *headers* and *proxy*
181+modules and create a `Location`_ configuration for the searx site. In most
182+distributions you have to uncomment the lines in the main configuration file,
183+except in the :ref:`The Debian Layout`.
187+ .. group-tab:: Ubuntu / debian
189+ In the Apache setup, enable headers and proxy modules:
193+ sudo -H a2enmod headers
194+ sudo -H a2enmod proxy
195+ sudo -H a2enmod proxy_http
197+ In :ref:`The Debian Layout` you create a ``searx.conf`` with the
198+ ``<Location /searx >`` directive and save this file in the *sites
199+ available* folder at ``/etc/apache2/sites-available``. To enable the
200+ ``searx.conf`` use :man:`a2ensite`:
204+ sudo -H a2ensite searx.conf
206+ .. group-tab:: Arch Linux
208+ In the ``/etc/httpd/conf/httpd.conf`` file, activate headers and proxy
209+ modules (LoadModule_):
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_):
224+ LoadModule headers_module modules/mod_headers.so
225+ LoadModule proxy_module modules/mod_proxy.so
226+ LoadModule proxy_http_module modules/mod_proxy_http.so
230+ .. group-tab:: searx via filtron plus morty
232+ Use this setup, if your instance is public to the internet, compare
233+ figure: :ref:`architecture <arch public>` and :ref:`installation scripts`.
235+ 1. Configure a reverse proxy for :ref:`filtron <filtron.sh>`, listening on
236+ *localhost 4004* (:ref:`filtron route request`):
242+ # SetEnvIf Request_URI "/searx" dontlog
243+ # CustomLog /dev/null combined env=dontlog
249+ #Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
252+ ProxyPreserveHost On
253+ ProxyPass http://127.0.0.1:4004
254+ RequestHeader set X-Script-Name /searx
258+ 2. Configure reverse proxy for :ref:`morty <searx morty>`, listening on
259+ *localhost 3000* (FYI: ``ProxyPreserveHost On`` is already set, see
264+ ProxyPreserveHost On
268+ # SetEnvIf Request_URI "/morty" dontlog
269+ # CustomLog /dev/null combined env=dontlog
275+ #Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
278+ ProxyPass http://127.0.0.1:3000
279+ RequestHeader set X-Script-Name /morty
283+ Note that reverse proxy advised to be used in case of single-user or
284+ low-traffic instances. For a fully result proxification add :ref:`morty's
285+ <searx morty>` **public URL** to your :origin:`searx/settings.yml`:
290+ # replace example.org with your server's public name
291+ url : https://example.org/morty
299+Be warned, with this setup, your instance isn't :ref:`protected <searx
300+filtron>`. Nevertheless it is good enough for intranet usage and it
301+demonstrates: *how different the uwsgi support is, depending on the
302+distribution*. To enable :ref:`uWSGI <searx uwsgi>` support you need to install
303+the apache `apache uwsgi`_ support:
@@ -27,59 +311,130 @@ Add wsgi mod
27 sudo -H apt-get install libapache2-mod-uwsgi
311 sudo -H apt-get install libapache2-mod-uwsgi
28 sudo -H a2enmod uwsgi
312 sudo -H a2enmod uwsgi
30−Add this configuration in the file ``/etc/apache2/apache2.conf``. To limit
314+ .. group-tab:: Arch Linux
31−acces to your intranet replace ``Allow from all`` directive and replace
315+
32−``192.168.0.0/16`` with your subnet IP/class.
316+ .. code:: sh
318+ sudo -H pacman -S uwsgi
34−.. _inranet apache site:
320+ In the ``/etc/httpd/conf/httpd.conf`` file, activate headers and proxy
321+ modules (LoadModule_):
36−Note that if your instance of searx is not at the root, you should change
323+ .. code:: apache
37−``<Location />`` by the location of your instance, like ``<Location /searx>``:
39−.. code:: apache
325+ LoadModule proxy_module modules/mod_proxy.so
326+ LoadModule proxy_uwsgi_module modules/mod_proxy_uwsgi.so
41− # CustomLog /dev/null combined
328+ .. group-tab:: Fedora / RHEL
43− <IfModule mod_uwsgi.c>
330+ .. code:: sh
45− <Location />
332+ sudo -H dnf install uwsgi
333+ FIXME: enable uwsgi in apache
47− Options FollowSymLinks Indexes
335+The next example shows a configuration using the `uWSGI Apache support`_ via
48− SetHandler uwsgi-handler
336+unix sockets. For socket communication, you have to activate ``socket =
49− uWSGISocket /run/uwsgi/app/searx/socket
337+/run/uwsgi/app/searx/socket`` and comment out the ``http = 127.0.0.1:8888``
338+configuration in your :ref:`uwsgi ini file <uwsgi configuration>`.
51− Order deny,allow
340+If not already exists, create a folder for the unix sockets, which can be
52− Deny from all
341+used by the searx account:
53− # Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
56− </Location>
343+.. code:: bash
58− </IfModule>
345+ sudo -H mkdir -p /run/uwsgi/app/searx/
346+ sudo -H chown -R searx:searx /run/uwsgi/app/searx/
60−Enable apache mod_uwsgi and restart apache:
348+To limit acces to your intranet replace ``Allow from all`` directive and replace
349+``192.168.0.0/16`` with your subnet IP/class.
64 .. group-tab:: Ubuntu / debian
353 .. group-tab:: Ubuntu / debian
66− .. code:: sh
355+ Debian uses the (old) `mod_uwsgi
356+ <https://uwsgi-docs.readthedocs.io/en/latest/Apache.html#mod-uwsgi>`_.
68− a2enmod uwsgi
358+ .. code:: apache
69− sudo -H systemctl restart apache2
71−disable logs
360+ <IfModule mod_uwsgi.c>
362+ # SetEnvIf Request_URI "/searx" dontlog
363+ # CustomLog /dev/null combined env=dontlog
369+ Options FollowSymLinks Indexes
370+ SetHandler uwsgi-handler
371+ uWSGISocket /run/uwsgi/app/searx/socket
375+ # Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
382+ .. group-tab:: Arch Linux
384+ Arch Linux uses the (recommend) `mod_proxy_uwsgi`_.
388+ <IfModule proxy_uwsgi_module>
390+ # SetEnvIf Request_URI /searx dontlog
391+ # CustomLog /dev/null combined env=dontlog
398+ # Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
401+ ProxyPreserveHost On
402+ ProxyPass unix:/run/uwsgi/app/searx/socket|uwsgi://uwsgi-uds-searx/
408+ .. group-tab:: Fedora / RHEL
410+ RHEL uses the (recommend) `mod_proxy_uwsgi`_.
74−For better privacy you can disable Apache logs. Go back to
412+ .. code:: apache
75−``/etc/apache2/apache2.conf`` :ref:`[example] <inranet apache site>` and above
76−``<Location />`` activate directive:
78−.. code:: apache
414+ <IfModule proxy_uwsgi_module>
416+ # SetEnvIf Request_URI /searx dontlog
80− CustomLog /dev/null combined
417+ # CustomLog /dev/null combined env=dontlog
424+ # Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
427+ ProxyPreserveHost On
428+ ProxyPass unix:/run/uwsgi/app/searx/socket|uwsgi://uwsgi-uds-searx/
82−Restart apache:
434+.. _restart apache:
@@ -88,8 +443,33 @@ Restart apache:
88 .. code:: sh
443 .. code:: sh
90 sudo -H systemctl restart apache2
445 sudo -H systemctl restart apache2
446+ sudo -H service uwsgi restart searx
448+ .. group-tab:: Arch Linux
452+ sudo -H systemctl restart httpd
453+ sudo -H systemctl restart uwsgi@searx
455+ .. group-tab:: Fedora / RHEL
459+ sudo -H systemctl restart httpd
460+ sudo -H touch /etc/uwsgi.d/searx.ini
466+For better privacy you can disable Apache logs. In the examples above activate
467+one of the lines and `restart apache`_::
92−.. warning::
470+ # SetEnvIf Request_URI "/searx" dontlog
471+ # CustomLog /dev/null combined env=dontlog
94− You can only disable logs for the whole (virtual) server not for a specific
473+The ``CustomLog`` directive disable logs for the whole (virtual) server, use it
95− path.
474+when the URL of the service does not have a path component (``/searx``) / is
475+located at root (``/``).