Skip to content

Instantly share code, notes, and snippets.

@unixfox
Last active October 11, 2023 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unixfox/4e22730769540fe5b9f1943a86439761 to your computer and use it in GitHub Desktop.
Save unixfox/4e22730769540fe5b9f1943a86439761 to your computer and use it in GitHub Desktop.
Mandatory change for SearXNG public instances!

Official discussion: searxng/searx-instances#417

By the 1st December 2023, we are going to make mandatory the setting "server.public_instance".

If you need help in configuring this new parameter please do not hesitate to ask for help:

This new parameter for the moment activate by default both the bot limiter AND the new advanced bot limiter called link_token. This is to improve the quality of the public instances by decreasing overal amount of bots harming the public instances.

It is very possible that in the future we will add more bot protection features enabled by default for you, but thanks to this new parameter you won't have to do anything. We will obviously announce any new bot protection feature.

We can make exceptions in case you really do not want to enable our bot limiter solution, but you will have to send us proofs: clearly stating how you detect bots, how you actively deal with them and also prove that it really works.

Basic tutorial

Only if you already have the limiter enabled, thus redis activated and your web server correctly configured! If you do not please see per type of installation.

  1. Update SearXNG to the latest version.
  2. Go to your settings.yml file
  3. Add the line public_instance: true in the section server:. Example:
server:
  public_instance: true
  1. Restart SearXNG

Per type of installation

searxng-docker

searxng-docker already have both the limiter and redis activated it's a simple change for you.

  1. Go to the directory of searxng-docker
  2. Update the directory by pulling the latest changes: git pull
  3. Edit the file settings.yml.
  4. Add the line public_instance: true in the section server:. Example:
server:
  public_instance: true
  1. Update SearXNG and restart it
docker-compose pull
docker-compose up -d
docker-compose restart

installation script (./utils/searxng.sh)

Depending on when you installed SearXNG you may already have the limiter and redis enabled.

1) Check if already have redis enabled or not

  1. View the file /etc/searxng/settings.yml with cat for example.
  2. If you already have url: unix:///usr/local/searxng-redis/run/redis.sock?db=0 then follow the first step, otherwise the second one.

2) Make the modifications in SearXNG

A) If you already have redis

  1. Pull the latest SearXNG changes:
./utils/searxng.sh update
  1. Edit the file /etc/searxng/settings.yml.
  2. Add the line public_instance: true in the section server:. Example:
server:
  public_instance: true
  1. Restart SearXNG:
service uwsgi restart searxng

Note: It may be another command but if you have installed SearXNG with uwsgi, it's this one.

B) If you do not have redis

  1. Pull the latest SearXNG changes:
./utils/searxng.sh update
  1. Install redis:
./utils/searxng.sh install redis

Accept all the steps, this may take a while.

  1. Edit the file /etc/searxng/settings.yml.
  2. Add the line public_instance: true in the section server:. Example:
server:
  public_instance: true
  1. Restart SearXNG:
service uwsgi restart searxng

Note: It may be another command but if you have installed SearXNG with uwsgi, it's this one.

3) Adapt your web server

Step by step installation (type) AND other types of custom installation (not Docker based)

You probably do not have redis enabled so you will have to configure redis.

1) Install Redis

  1. Install redis with your package manager. On debian/ubuntu: sudo apt install redis
  2. Edit the redis config file: /etc/redis/redis.conf
  3. Check that you have redis running on localhost, check if the lines bind 127.0.0.1 -::1 and port 6379 exist, if not add them.
  4. Restart redis if needed (above line modified or not).

2) Configure redis and new parameter in SearXNG

  1. Update SearXNG to the latest version. Probably with git pull.
  2. Edit your settings.yml. It is very probably at /etc/searxng/settings.yml.
  3. Add the line public_instance: true in the section server:. Example:
server:
  public_instance: true
  1. In the section redis:, add the line url: redis://localhost:6379/1:
redis:
  url: redis://localhost:6379/1

Please see the documentation for further details: https://docs.searxng.org/admin/settings/settings_redis.html#settings-redis

  1. Restart SearXNG

3) Adapt your web server

The point is to have the headers X-Real-IP and X-Forwarded-For correctly sent to the SearXNG server.

Any other non official installation - Docker based

1) Redis and configure SearXNG

  1. Install Redis locally. If you are on Docker add it for example in your docker-compose.yml file.
services:
  redis:
    image: redis:alpine
  1. Update SearXNG to the latest version. Probably with git pull or docker compose pull then docker compose up -d.
  2. Edit your settings.yml. It is very probably at /etc/searxng/settings.yml.
  3. Add this line for the server: section:
server:
  public_instance: true
  1. In the section redis:, add the line url: redis://localhost:6379/1:
redis:
  url: redis://localhost:6379/1

Please see the documentation for further details: https://docs.searxng.org/admin/settings/settings_redis.html#settings-redis

If you are on Docker, for redis use this line instead: redis://redis:6379/1

  1. Restart SearXNG

2) Adapt your web server

The point is to have the headers X-Real-IP and X-Forwarded-For correctly sent to the SearXNG server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment