searxng/docs/admin/installation-nginx.rst
Markus Heiser 5720844fcd [doc] rearranges Settings & Engines docs for better readability
We have built up detailed documentation of the *settings* and the *engines* over
the past few years.  However, this documentation was still spread over various
chapters and was difficult to navigate in its entirety.

This patch rearranges the Settings & Engines documentation for better
readability.

To review new ordered docs::

   make docs.clean docs.live

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-07-01 22:45:19 +02:00

5.9 KiB

NGINX

This section explains how to set up a SearXNG instance using the HTTP server nginx. If you have used the installation scripts and do not have any special preferences you can install the SearXNG site <nginx searxng site> using searxng.sh <searxng.sh overview>:

$ sudo -H ./utils/searxng.sh install nginx

If you have special interests or problems with setting up nginx, the following section might give you some guidance.

The nginx HTTP server

If nginx is not installed, install it now.

Ubuntu / debian

sudo -H apt-get install nginx

Arch Linux

sudo -H pacman -S nginx-mainline
sudo -H systemctl enable nginx
sudo -H systemctl start nginx

Fedora / RHEL

sudo -H dnf install nginx
sudo -H systemctl enable nginx
sudo -H systemctl start nginx

Now at http://localhost you should see a Welcome to nginx! page, on Fedora you see a Fedora Webserver - Test Page. The test page comes from the default nginx server configuration. How this default site is configured, depends on the linux distribution:

Ubuntu / debian

less /etc/nginx/nginx.conf

There is one line that includes site configurations from:

include /etc/nginx/sites-enabled/*;

Arch Linux

less /etc/nginx/nginx.conf

There is a configuration section named server:

server {
    listen       80;
    server_name  localhost;
    # ...
}

Fedora / RHEL

less /etc/nginx/nginx.conf

There is one line that includes site configurations from:

include /etc/nginx/conf.d/*.conf;

NGINX's SearXNG site

Now you have to create a configuration file (searxng.conf) for the SearXNG site. If nginx is new to you, the nginx beginners guide is a good starting point and the Getting Started wiki is always a good resource to keep in the pocket.

Depending on what your SearXNG installation is listening on, you need a http or socket communication to upstream.

socket

$DOCS_BUILD/includes/searxng.rst

http

$DOCS_BUILD/includes/searxng.rst

The installation scripts installs the reference setup <use_default_settings.yml> and a uwsgi setup that listens on a socket by default.

Ubuntu / debian

Create configuration at /etc/nginx/sites-available/ and place a symlink to sites-enabled:

sudo -H ln -s /etc/nginx/sites-available/searxng.conf \
              /etc/nginx/sites-enabled/searxng.conf

Arch Linux

In the /etc/nginx/nginx.conf file, in the server section add a include directive:

server {
    # ...
    include /etc/nginx/default.d/*.conf;
    # ...
}

Create two folders, one for the available sites and one for the enabled sites:

mkdir -p /etc/nginx/default.d
mkdir -p /etc/nginx/default.apps-available

Create configuration at /etc/nginx/default.apps-available and place a symlink to default.d:

sudo -H ln -s /etc/nginx/default.apps-available/searxng.conf \
              /etc/nginx/default.d/searxng.conf

Fedora / RHEL

Create a folder for the available sites:

mkdir -p /etc/nginx/default.apps-available

Create configuration at /etc/nginx/default.apps-available and place a symlink to conf.d:

sudo -H ln -s /etc/nginx/default.apps-available/searxng.conf \
              /etc/nginx/conf.d/searxng.conf

Restart services:

Ubuntu / debian

sudo -H systemctl restart nginx
sudo -H service uwsgi restart searxng

Arch Linux

sudo -H systemctl restart nginx
sudo -H systemctl restart uwsgi@searxng

Fedora / RHEL

sudo -H systemctl restart nginx
sudo -H touch /etc/uwsgi.d/searxng.ini

Disable logs

For better privacy you can disable nginx logs in /etc/nginx/nginx.conf.

http {
    # ...
    access_log /dev/null;
    error_log  /dev/null;
    # ...
}