2020-02-04 15:42:13 +00:00
|
|
|
.. _installation nginx:
|
|
|
|
|
|
|
|
==================
|
|
|
|
Install with nginx
|
|
|
|
==================
|
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
.. _nginx:
|
|
|
|
https://docs.nginx.com/nginx/admin-guide/
|
|
|
|
.. _nginx server configuration:
|
|
|
|
https://docs.nginx.com/nginx/admin-guide/web-server/web-server/#setting-up-virtual-servers
|
|
|
|
.. _nginx beginners guide:
|
2020-12-04 15:50:26 +00:00
|
|
|
https://nginx.org/en/docs/beginners_guide.html
|
2020-03-04 18:56:40 +00:00
|
|
|
.. _Getting Started wiki:
|
|
|
|
https://www.nginx.com/resources/wiki/start/
|
2020-03-06 13:47:00 +00:00
|
|
|
.. _uWSGI support from nginx:
|
|
|
|
https://uwsgi-docs.readthedocs.io/en/latest/Nginx.html
|
|
|
|
.. _uwsgi_params:
|
|
|
|
https://uwsgi-docs.readthedocs.io/en/latest/Nginx.html#configuring-nginx
|
|
|
|
.. _SCRIPT_NAME:
|
|
|
|
https://werkzeug.palletsprojects.com/en/1.0.x/wsgi/#werkzeug.wsgi.get_script_name
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-04-09 13:04:23 +00:00
|
|
|
.. sidebar:: further reading
|
|
|
|
|
|
|
|
- nginx_
|
|
|
|
- `nginx beginners guide`_
|
|
|
|
- `nginx server configuration`_
|
|
|
|
- `Getting Started wiki`_
|
|
|
|
- `uWSGI support from nginx`_
|
|
|
|
|
2020-02-04 15:42:13 +00:00
|
|
|
.. contents:: Contents
|
|
|
|
:depth: 2
|
|
|
|
:local:
|
|
|
|
:backlinks: entry
|
|
|
|
|
2020-04-13 11:00:03 +00:00
|
|
|
----
|
|
|
|
|
|
|
|
**Install** :ref:`nginx searx site` using :ref:`filtron.sh <filtron.sh overview>`
|
|
|
|
|
|
|
|
.. code:: bash
|
|
|
|
|
|
|
|
$ sudo -H ./utils/filtron.sh nginx install
|
|
|
|
|
|
|
|
**Install** :ref:`nginx searx site` using :ref:`morty.sh <morty.sh overview>`
|
|
|
|
|
|
|
|
.. code:: bash
|
|
|
|
|
|
|
|
$ sudo -H ./utils/morty.sh nginx install
|
|
|
|
|
|
|
|
----
|
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
|
|
|
|
The nginx HTTP server
|
|
|
|
=====================
|
|
|
|
|
2020-04-06 15:59:06 +00:00
|
|
|
If nginx_ is not installed (uwsgi will not work with the package nginx-light),
|
2020-03-04 18:56:40 +00:00
|
|
|
install it now.
|
|
|
|
|
2020-02-04 15:42:13 +00:00
|
|
|
.. tabs::
|
|
|
|
|
|
|
|
.. group-tab:: Ubuntu / debian
|
|
|
|
|
|
|
|
.. code:: sh
|
|
|
|
|
|
|
|
sudo -H apt-get install nginx
|
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
.. group-tab:: Arch Linux
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
.. code-block:: sh
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
sudo -H pacman -S nginx-mainline
|
|
|
|
sudo -H systemctl enable nginx
|
|
|
|
sudo -H systemctl start nginx
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
.. group-tab:: Fedora / RHEL
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
.. code-block:: sh
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
sudo -H dnf install nginx
|
|
|
|
sudo -H systemctl enable nginx
|
|
|
|
sudo -H systemctl start nginx
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
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
|
2020-04-06 15:59:06 +00:00
|
|
|
`nginx server configuration`_. How this default intro site is configured,
|
|
|
|
depends on the linux distribution:
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
.. tabs::
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
.. group-tab:: Ubuntu / debian
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
.. code:: sh
|
|
|
|
|
|
|
|
less /etc/nginx/nginx.conf
|
|
|
|
|
|
|
|
there is a line including site configurations from:
|
|
|
|
|
|
|
|
.. code:: nginx
|
|
|
|
|
|
|
|
include /etc/nginx/sites-enabled/*;
|
|
|
|
|
|
|
|
.. group-tab:: Arch Linux
|
|
|
|
|
|
|
|
.. code-block:: sh
|
|
|
|
|
|
|
|
less /etc/nginx/nginx.conf
|
|
|
|
|
|
|
|
in there is a configuration section named ``server``:
|
|
|
|
|
|
|
|
.. code-block:: nginx
|
|
|
|
|
|
|
|
server {
|
|
|
|
listen 80;
|
|
|
|
server_name localhost;
|
|
|
|
# ...
|
|
|
|
}
|
|
|
|
|
|
|
|
.. group-tab:: Fedora / RHEL
|
|
|
|
|
|
|
|
.. code-block:: sh
|
|
|
|
|
|
|
|
less /etc/nginx/nginx.conf
|
|
|
|
|
|
|
|
there is a line including site configurations from:
|
|
|
|
|
|
|
|
.. code:: nginx
|
|
|
|
|
|
|
|
include /etc/nginx/conf.d/*.conf;
|
|
|
|
|
|
|
|
.. _nginx searx site:
|
|
|
|
|
2020-03-06 13:47:00 +00:00
|
|
|
A nginx searx site
|
|
|
|
==================
|
2020-03-04 18:56:40 +00:00
|
|
|
|
|
|
|
.. sidebar:: public to the internet?
|
|
|
|
|
|
|
|
If your searx instance is public, stop here and first install :ref:`filtron
|
|
|
|
reverse proxy <filtron.sh>` and :ref:`result proxy morty <morty.sh>`, see
|
2020-04-06 15:59:06 +00:00
|
|
|
:ref:`installation scripts`. If already done, follow setup: *searx via
|
|
|
|
filtron plus morty*.
|
2020-03-04 18:56:40 +00:00
|
|
|
|
|
|
|
Now you have to create a configuration for the searx 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*.
|
2020-02-04 15:42:13 +00:00
|
|
|
|
|
|
|
.. tabs::
|
|
|
|
|
|
|
|
.. group-tab:: Ubuntu / debian
|
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
Create configuration at ``/etc/nginx/sites-available/searx`` and place a
|
|
|
|
symlink to sites-enabled:
|
|
|
|
|
2020-02-04 15:42:13 +00:00
|
|
|
.. code:: sh
|
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
sudo -H ln -s /etc/nginx/sites-available/searx /etc/nginx/sites-enabled/searx
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
.. group-tab:: Arch Linux
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
In the ``/etc/nginx/nginx.conf`` file, replace the configuration section
|
|
|
|
named ``server``.
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
.. group-tab:: Fedora / RHEL
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
Create configuration at ``/etc/nginx/conf.d/searx`` and place a
|
|
|
|
symlink to sites-enabled:
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2021-01-27 08:58:06 +00:00
|
|
|
.. _nginx searx via filtron plus morty:
|
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
.. tabs::
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-06 13:47:00 +00:00
|
|
|
.. group-tab:: searx via filtron plus morty
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-06 13:47:00 +00:00
|
|
|
Use this setup, if your instance is public to the internet, compare
|
2020-04-06 15:59:06 +00:00
|
|
|
figure: :ref:`architecture <arch public>` and :ref:`installation scripts`.
|
|
|
|
|
|
|
|
1. Configure a reverse proxy for :ref:`filtron <filtron.sh>`, listening on
|
|
|
|
*localhost 4004* (:ref:`filtron route request`):
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
.. code:: nginx
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-04-11 11:19:11 +00:00
|
|
|
# https://example.org/searx
|
2020-03-06 13:47:00 +00:00
|
|
|
|
2020-04-11 11:19:11 +00:00
|
|
|
location /searx {
|
|
|
|
proxy_pass http://127.0.0.1:4004/;
|
|
|
|
|
2021-03-03 11:21:06 +00:00
|
|
|
proxy_set_header Host $host;
|
2020-04-11 11:19:11 +00:00
|
|
|
proxy_set_header Connection $http_connection;
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header X-Scheme $scheme;
|
|
|
|
proxy_set_header X-Script-Name /searx;
|
|
|
|
}
|
|
|
|
|
2021-03-03 11:21:06 +00:00
|
|
|
location /searx/static/ {
|
|
|
|
alias /usr/local/searx/searx-src/searx/static/;
|
2020-04-11 11:19:11 +00:00
|
|
|
}
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-06 13:47:00 +00:00
|
|
|
|
2020-04-06 15:59:06 +00:00
|
|
|
2. Configure reverse proxy for :ref:`morty <searx morty>`, listening on
|
|
|
|
*localhost 3000*:
|
2020-03-06 13:47:00 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
.. code:: nginx
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-04-11 11:19:11 +00:00
|
|
|
# https://example.org/morty
|
|
|
|
|
|
|
|
location /morty {
|
2020-03-04 18:56:40 +00:00
|
|
|
proxy_pass http://127.0.0.1:3000/;
|
2020-03-06 13:47:00 +00:00
|
|
|
|
2021-03-03 11:21:06 +00:00
|
|
|
proxy_set_header Host $host;
|
2020-04-11 11:19:11 +00:00
|
|
|
proxy_set_header Connection $http_connection;
|
2020-03-06 13:47:00 +00:00
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header X-Scheme $scheme;
|
2020-03-04 18:56:40 +00:00
|
|
|
}
|
|
|
|
|
2021-01-27 08:58:06 +00:00
|
|
|
For a fully result proxification add :ref:`morty's <searx morty>` **public
|
|
|
|
URL** to your :origin:`searx/settings.yml`:
|
2020-03-04 18:56:40 +00:00
|
|
|
|
|
|
|
.. code:: yaml
|
|
|
|
|
|
|
|
result_proxy:
|
2020-03-06 14:04:12 +00:00
|
|
|
# replace example.org with your server's public name
|
2020-04-06 15:59:06 +00:00
|
|
|
url : https://example.org/morty
|
2021-01-27 08:58:06 +00:00
|
|
|
key : !!binary "insert_your_morty_proxy_key_here"
|
2020-04-06 15:59:06 +00:00
|
|
|
|
|
|
|
server:
|
|
|
|
image_proxy : True
|
2020-03-04 18:56:40 +00:00
|
|
|
|
|
|
|
|
2021-01-27 08:58:06 +00:00
|
|
|
.. group-tab:: proxy or uWSGI
|
2020-03-04 18:56:40 +00:00
|
|
|
|
2020-03-06 21:06:19 +00:00
|
|
|
Be warned, with this setup, your instance isn't :ref:`protected <searx
|
2020-03-06 13:47:00 +00:00
|
|
|
filtron>`. Nevertheless it is good enough for intranet usage and it is a
|
|
|
|
excellent example of; *how different services can be set up*. The next
|
|
|
|
example shows a reverse proxy configuration wrapping the :ref:`searx-uWSGI
|
|
|
|
application <uwsgi configuration>`, listening on ``http =
|
|
|
|
127.0.0.1:8888``.
|
2020-03-04 18:56:40 +00:00
|
|
|
|
|
|
|
.. code:: nginx
|
|
|
|
|
2020-04-11 11:19:11 +00:00
|
|
|
# https://hostname.local/
|
2020-03-04 18:56:40 +00:00
|
|
|
|
2020-04-11 11:19:11 +00:00
|
|
|
location / {
|
|
|
|
proxy_pass http://127.0.0.1:8888;
|
|
|
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
proxy_set_header Connection $http_connection;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header X-Scheme $scheme;
|
|
|
|
proxy_buffering off;
|
|
|
|
}
|
2020-03-06 13:47:00 +00:00
|
|
|
|
|
|
|
Alternatively you can use the `uWSGI support from nginx`_ via unix
|
|
|
|
sockets. For socket communication, you have to activate ``socket =
|
|
|
|
/run/uwsgi/app/searx/socket`` and comment out the ``http =
|
|
|
|
127.0.0.1:8888`` configuration in your :ref:`uwsgi ini file <uwsgi
|
|
|
|
configuration>`.
|
|
|
|
|
|
|
|
The example shows a nginx virtual ``server`` configuration, listening on
|
|
|
|
port 80 (IPv4 and IPv6 http://[::]:80). The uWSGI app is configured at
|
|
|
|
location ``/`` by importing the `uwsgi_params`_ and passing requests to
|
|
|
|
the uWSGI socket (``uwsgi_pass``). The ``server``\'s root points to the
|
|
|
|
:ref:`searx-src clone <searx-src>` and wraps directly the
|
|
|
|
:origin:`searx/static/` content at ``location /static``.
|
|
|
|
|
|
|
|
.. code:: nginx
|
|
|
|
|
|
|
|
server {
|
2020-04-11 11:19:11 +00:00
|
|
|
# replace hostname.local with your server's name
|
|
|
|
server_name hostname.local;
|
2020-03-04 18:56:40 +00:00
|
|
|
|
2020-03-06 13:47:00 +00:00
|
|
|
listen 80;
|
|
|
|
listen [::]:80;
|
2020-03-04 18:56:40 +00:00
|
|
|
|
|
|
|
location / {
|
|
|
|
include uwsgi_params;
|
|
|
|
uwsgi_pass unix:/run/uwsgi/app/searx/socket;
|
|
|
|
}
|
2020-03-06 13:47:00 +00:00
|
|
|
|
2020-04-11 11:19:11 +00:00
|
|
|
root /usr/local/searx/searx-src/searx;
|
2020-03-06 13:47:00 +00:00
|
|
|
location /static { }
|
2020-03-04 18:56:40 +00:00
|
|
|
}
|
|
|
|
|
2020-03-06 13:47:00 +00:00
|
|
|
If not already exists, create a folder for the unix sockets, which can be
|
|
|
|
used by the searx account:
|
2020-03-04 18:56:40 +00:00
|
|
|
|
2020-03-06 13:47:00 +00:00
|
|
|
.. code:: bash
|
2020-03-04 18:56:40 +00:00
|
|
|
|
2020-04-11 11:19:11 +00:00
|
|
|
mkdir -p /run/uwsgi/app/searx/
|
|
|
|
sudo -H chown -R searx:searx /run/uwsgi/app/searx/
|
2020-03-04 18:56:40 +00:00
|
|
|
|
2020-04-11 11:19:11 +00:00
|
|
|
.. group-tab:: \.\. at subdir URL
|
2020-03-06 13:47:00 +00:00
|
|
|
|
2020-03-06 21:06:19 +00:00
|
|
|
Be warned, with these setups, your instance isn't :ref:`protected <searx
|
2020-03-06 13:47:00 +00:00
|
|
|
filtron>`. The examples are just here to demonstrate how to export the
|
2020-03-06 14:04:12 +00:00
|
|
|
searx application from a subdirectory URL ``https://example.org/searx/``.
|
2020-03-06 13:47:00 +00:00
|
|
|
|
|
|
|
.. code:: nginx
|
2020-03-04 18:56:40 +00:00
|
|
|
|
2020-04-11 11:19:11 +00:00
|
|
|
# https://hostname.local/searx
|
2020-03-06 13:47:00 +00:00
|
|
|
|
2020-04-11 11:19:11 +00:00
|
|
|
location /searx {
|
|
|
|
proxy_pass http://127.0.0.1:8888;
|
|
|
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
proxy_set_header Connection $http_connection;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header X-Scheme $scheme;
|
|
|
|
proxy_set_header X-Script-Name /searx;
|
|
|
|
proxy_buffering off;
|
|
|
|
}
|
2020-03-04 18:56:40 +00:00
|
|
|
|
2021-03-03 11:21:06 +00:00
|
|
|
location /searx/static/ {
|
|
|
|
alias /usr/local/searx/searx-src/searx/static/;
|
2020-04-11 11:19:11 +00:00
|
|
|
}
|
2020-03-04 18:56:40 +00:00
|
|
|
|
2020-03-06 13:47:00 +00:00
|
|
|
The ``X-Script-Name /searx`` is needed by the searx implementation to
|
|
|
|
calculate relative URLs correct. The next example shows a uWSGI
|
|
|
|
configuration. Since there are no HTTP headers in a (u)WSGI protocol, the
|
|
|
|
value is shipped via the SCRIPT_NAME_ in the WSGI environment.
|
2020-03-04 18:56:40 +00:00
|
|
|
|
|
|
|
.. code:: nginx
|
|
|
|
|
2020-04-11 11:19:11 +00:00
|
|
|
# https://hostname.local/searx
|
|
|
|
|
|
|
|
location /searx {
|
|
|
|
uwsgi_param SCRIPT_NAME /searx;
|
|
|
|
include uwsgi_params;
|
|
|
|
uwsgi_pass unix:/run/uwsgi/app/searx/socket;
|
|
|
|
}
|
2020-03-04 18:56:40 +00:00
|
|
|
|
2021-03-03 11:21:06 +00:00
|
|
|
location /searx/static/ {
|
|
|
|
alias /usr/local/searx/searx-src/searx/;
|
2020-04-11 11:19:11 +00:00
|
|
|
}
|
2020-03-04 18:56:40 +00:00
|
|
|
|
2020-03-06 13:47:00 +00:00
|
|
|
For searx to work correctly the ``base_url`` must be set in the
|
|
|
|
:origin:`searx/settings.yml`.
|
2020-03-04 18:56:40 +00:00
|
|
|
|
|
|
|
.. code:: yaml
|
|
|
|
|
|
|
|
server:
|
2020-03-06 14:04:12 +00:00
|
|
|
# replace example.org with your server's public name
|
|
|
|
base_url : https://example.org/searx/
|
2020-02-04 15:42:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
Restart service:
|
|
|
|
|
|
|
|
.. tabs::
|
|
|
|
|
|
|
|
.. group-tab:: Ubuntu / debian
|
|
|
|
|
|
|
|
.. code:: sh
|
|
|
|
|
|
|
|
sudo -H systemctl restart nginx
|
2020-03-06 13:47:00 +00:00
|
|
|
sudo -H service uwsgi restart searx
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
.. group-tab:: Arch Linux
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
.. code:: sh
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
sudo -H systemctl restart nginx
|
2020-03-06 13:47:00 +00:00
|
|
|
sudo -H systemctl restart uwsgi@searx
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
.. group-tab:: Fedora
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
.. code:: sh
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
sudo -H systemctl restart nginx
|
2020-03-06 13:47:00 +00:00
|
|
|
sudo -H touch /etc/uwsgi.d/searx.ini
|
2020-02-04 15:42:13 +00:00
|
|
|
|
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
Disable logs
|
|
|
|
============
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
For better privacy you can disable nginx logs in ``/etc/nginx/nginx.conf``.
|
2020-02-04 15:42:13 +00:00
|
|
|
|
2020-03-04 18:56:40 +00:00
|
|
|
.. code:: nginx
|
|
|
|
|
|
|
|
http {
|
|
|
|
# ...
|
|
|
|
access_log /dev/null;
|
|
|
|
error_log /dev/null;
|
|
|
|
# ...
|
|
|
|
}
|