serveur_hebergement:installer_une_instance_searx

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
serveur_hebergement:installer_une_instance_searx [2022/10/02 17:46] – [Préparation] fateserveur_hebergement:installer_une_instance_searx [2026/08/11 15:39] (Version actuelle) fate
Ligne 1: Ligne 1:
-====== Installer une instance Searx ======+====== Searxng ======
  
-===== Présentation de Searx =====+===== Présentation de Searxng ===== 
 + 
 +[[https://github.com/searxngng/searxng|Searxng]] est un métamoteur de recherche libre, c’est-à-dire qu'il ne gère pas lui-même la recherche mais s'appuie sur des moteurs de recherches tels que bing, google, duckduckgo, etc.
  
 ===== Préparation ===== ===== Préparation =====
  
-Installez les dépendances : <code bash>sudo aptitude install python3-dev python3-babel python3-venv uwsgi uwsgi-plugin-python3 git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev shellcheck libapache2-mod-proxy-uwsgi</code>+On va déployer Searxng via docker, donc il faut que docker-compose soit installé sur votre système
  
-Créez un utilisateur searx :  +===== Installation de Searxng =====
-<code bash>sudo useradd --shell /bin/bash --system --home-dir "/usr/local/searx" --comment 'Privacy-respecting metasearch engine' searx</code>+
  
-Créez le répertoire home :  +Créer un répertoire Searxng et dans ce répertoire, créez le fichier docker-compose.yml avec ce contenu 
-<code bash>sudo  mkdir "/usr/local/searx"</code>+<code bash> 
 +# Read the documentation before using the `docker-compose.yml` file: 
 +# https://docs.searxng.org/admin/installation-docker.html
  
-Modifiez le propriétaire du répertoire home : +namesearxng
-<code bash>sudo  chown -R "searx:searx" "/usr/local/searx"</code>+
  
-===== Installation de Searx =====+services: 
 +  core: 
 +    container_name: searxng-core 
 +    image: docker.io/searxng/searxng:${SEARXNG_VERSION:-latest} 
 +    restart: always 
 +    ports: 
 +      - ${SEARXNG_HOST:+${SEARXNG_HOST}:}${SEARXNG_PORT:-8080}:${SEARXNG_PORT:-8080} 
 +    env_file: ./.env 
 +    volumes: 
 +      - ./core-config/:/etc/searxng/:
 +      - ./core-data:/var/cache/searxng/
  
-Connectez-vous avec l'utilisateur searx :  +  valkey: 
-<code bash>sudo  -u searx -i</code>+    container_name: searxng-valkey 
 +    imagedocker.io/valkey/valkey:9-alpine 
 +    command: valkey-server --save 30 1 --loglevel warning 
 +    restart: always 
 +    volumes: 
 +      - ./valkey-data:/data/
  
-Récupérez les sources de Searx +volumes
-<code bash>git clone "https://github.com/searx/searx.git" "/usr/local/searx/searx-src"</code>+  core-data: 
 +  valkey-data: 
 +</code>
  
-Créez l'environnement Python +Dans le même répertoire, créez le fichier .env avec le contenu suivant (vous pouvez modifier le port 8085) :  
-<code bash>python3 -m venv "/usr/local/searx/searx-pyenv"</code>+<code bash> 
 +# Read the documentation before using the `docker-compose.yml` file: 
 +# https://docs.searxng.org/admin/installation-docker.html 
 +
 +# Additional ENVs: 
 +# https://docs.searxng.org/admin/settings/settings_general.html#settings-general 
 +# https://docs.searxng.org/admin/settings/settings_server.html#settings-server
  
-Activez-le à chaque connexion : +# Use a specific version tag. E.g. "latestor "2026.3.25-541c6c3cb"
-<code bash>echo "/usr/local/searx/searx-pyenv/bin/activate>>  "/usr/local/searx/.profile"</code>+SEARXNG_VERSION=latest
  
-Déconnectez vous avec la commande <code bash>exit</code> +# Listen to a specific address. 
-Connectez-vous de nouveau avec l'utilisateur searx : +SEARXNG_HOST=[127.0.0.1]
-<code bash>sudo  -u searx -i</code>+
  
-Mettre à jour les modules nécessaires :  +# Listen to a specific port. 
-<code bash> +SEARXNG_PORT=8085
-pip install -U pip +
-pip install -U setuptools +
-pip install -U wheel +
-pip install -U pyyaml+
 </code> </code>
  
-Lancez l'installation +Lancez la commande suivante pour démarrer le conteneur :  
-<code bash> +<code bash>sudo docker compose up -d</code>
-cd "/usr/local/searx/searx-src" +
-pip install -e . +
-</code>+
  
 ===== Configuration ===== ===== Configuration =====
  
-Dans un autre terminal, copiez le fichier de configuration par défaut :+Ouvrez le fichier core-config/settings.yml et modifiez-le comme suit :
 <code bash> <code bash>
-sudo  mkdir -p "/etc/searx" +# Read the documentation before extending the defaults: 
-sudo  cp "/usr/local/searx/searx-src/utils/templates/etc/searx/use_default_settings.yml" "/etc/searx/settings.yml" +# https://docs.searxng.org/admin/settings/
-</code>+
  
-Ouvrez le fichier /etc/searx/settings.yml et remplacez la valeur de la secret_key par une suite de chiffres et de lettres.+use_default_settings: true
  
-Pour vérifiez que Searx se lance sans problème, activez le debug +server
-<code bash>sudo  sed -i -e "s/debug False/debug : True/g" "/etc/searx/settings.yml"</code> +  secret_key: "dQmtqyS1rEuuFLQgW0xHgFSQ2CP5cZS
- +  image_proxy: true 
-Connectez-vous de nouveau avec l'utilisateur searx si vous vous êtes déconnectés +  limiter: true 
-<code bash>sudo  -u searx -i</code>+valkey
 +  url: valkey://valkey:6379/
 +</code>
  
-Puis lancez searx +Si vous voulez rendre mon instance privée mais accessible depuis n'importe quelle IP, vous pouvez utilisez le système de jeton. Dans votre fichier settings.yml, ajoutez les lignes suivantes 
 <code bash> <code bash>
-cd /usr/local/searx/searx-src +engines: 
-export SEARX_SETTINGS_PATH="/etc/searx/settings.yml" +  name: google cse 
-python searx/webapp.py+    tokens: ['MonMotDePasseSecret123!'
 +  - name: bing 
 +    tokens: ['MonMotDePasseSecret123!'
 +  - name: duckduckgo 
 +    tokens: ['MonMotDePasseSecret123!']
 </code> </code>
  
-Désactivez le mode debug : +Pour pouvoir accéder à ces moteurs, vous devez coller votre token (ça peut être le même pour tous les moteurs) dans l'interface web de Searxng dans Préférences Général Jetons de moteur
-<code bash>sudo  sed -i -e "s/debug : True/debug : False/g" "/etc/searx/settings.yml"</code>+
  
-===== uWSGI =====+Créez le fichier core-config/limiter.toml et collez-y le contenu suivant :  
 +<code bash> 
 +[botdetection.ip_limit]
  
-uWSGI va nous permettre de démarrer l'instance Searx.+# To get unlimited access in a local network, by default link-local addresses 
 +# (networks) are not monitored by the ip_limit 
 +filter_link_local = false
  
-Créez le fichier de configuration pour uWSGI : +# activate link_token method in the ip_limit method 
-<code bash>sudo nano /etc/uwsgi/apps-available/searx.ini</code>+link_token = true 
 +</code>
  
-Collez-y les lignes suivantes :+Redémarrez le conteneur 
 <code bash> <code bash>
-[uwsgi] +sudo docker compose down 
- +sudo docker compose up -d
-# uWSGI core +
----------- +
-+
-# https://uwsgi-docs.readthedocs.io/en/latest/Options.html#uwsgi-core +
- +
-# Who will run the code +
-uid = searx +
-gid = searx +
- +
-# set (python) default encoding UTF-8 +
-env = LANG=C.UTF-8 +
-env = LANGUAGE=C.UTF-8 +
-env = LC_ALL=C.UTF-8 +
- +
-# chdir to specified directory before apps loading +
-chdir = /usr/local/searx/searx-src/searx +
- +
-# searx configuration (settings.yml) +
-env = SEARX_SETTINGS_PATH=/etc/searx/settings.yml +
- +
-# disable logging for privacy +
-disable-logging = true +
- +
-# The right granted on the created socket +
-chmod-socket = 666 +
- +
-# Plugin to use and interpreter config +
-single-interpreter = true +
- +
-# enable master process +
-master = true +
- +
-# load apps in each worker instead of the master +
-lazy-apps = true +
- +
-# load uWSGI plugins +
-plugin = python3,http +
- +
-# By default the Python plugin does not initialize the GIL.  This means your +
-# app-generated threads will not run.  If you need threads, remember to enable +
-# them with enable-threads.  Running uWSGI in multithreading mode (with the +
-# threads options) will automatically enable threading support. This *strange* +
-# default behaviour is for performance reasons. +
-enable-threads = true +
- +
- +
-# plugin: python +
-# -------------- +
-+
-# https://uwsgi-docs.readthedocs.io/en/latest/Options.html#plugin-python +
- +
-# load a WSGI module +
-module = searx.webapp +
- +
-# set PYTHONHOME/virtualenv +
-virtualenv = /usr/local/searx/searx-pyenv +
- +
-# add directory (or glob) to pythonpath +
-pythonpath = /usr/local/searx/searx-src +
- +
- +
-# speak to upstream +
-# ----------------- +
-+
-# Activate the 'http' configuration for filtron or activate the 'socket' +
-# configuration if you setup your HTTP server to use uWSGI protocol via sockets. +
- +
-# using IP: +
-+
-# https://uwsgi-docs.readthedocs.io/en/latest/Options.html#pluginttp +
-# Native HTTP support: https://uwsgi-docs.readthedocs.io/en/latest/HTTP.html +
- +
-http = 127.0.0.1:8888 +
- +
-# using unix-sockets: +
-+
-# On some distributions you need to create the app folder for the sockets:: +
-+
-#   mkdir -p /run/uwsgi/app/searx +
-#   chown -R searx:searx  /run/uwsgi/app/searx +
-+
-# socket = /run/uwsgi/app/searx/socket +
- +
-# Cache +
-cache2 = name=searxcache,items=2000,blocks=2000,blocksize=4096,bitmap=1+
 </code> </code>
-  
-Activez le lancement au démarrage de Searx : 
-<code bash>sudo ln -s /etc/uwsgi/apps-available/searx.ini /etc/uwsgi/apps-enabled/</code> 
- 
-Démarrez Searx : 
-<code bash>sudo service uwsgi start searx</code> 
  
 ===== Configuration d'Apache ===== ===== Configuration d'Apache =====
  
-On va configurer Apache2 pour pour voir accéder à notre instance Searx via un sous domaine style searx.domaine.fr (je ne traiterai pas la gestion du nom de domaine)+On va configurer Apache2 pour pouvoir accéder à notre instance Searx via un sous domaine style searx.domaine.fr (je ne traiterai pas la gestion du nom de domaine)
  
 Activez les modules Apache2 nécessaires : Activez les modules Apache2 nécessaires :
-<code bash>sudo a2enmod headers proxy proxy_http</code>+<code bash>sudo a2enmod headers proxy proxy_http ssl proxy_uwsgi</code>
  
 Créez le fichier de config Apache2 : Créez le fichier de config Apache2 :
 <code bash>sudo nano /etc/apache2/sites-available/searx.domaine.fr.conf</code> <code bash>sudo nano /etc/apache2/sites-available/searx.domaine.fr.conf</code>
  
-Copiez-y les lignes suivantes (remplacez le noom de domaine par le votre ainsi que l'emplacement des fichiers SSL) : +Copiez-y les lignes suivantes (remplacez le nom de domaine par le vôtre ainsi que l'emplacement des fichiers SSL et le numéro de port) : 
 <code apache> <code apache>
 <VirtualHost *:80> <VirtualHost *:80>
  
-        ServerName searx.nomdedomaine.fr +        ServerName searx.domaine.fr
-        ServerAdmin fate@nomdedomaine.fr+
  
-        Redirect / https://searx.nomdedomaine.fr/+        Redirect / https://searx.domaine.fr/
  
 </VirtualHost> </VirtualHost>
 +
 +
 +<VirtualHost *:443>
 +
 +        ServerName searx.domaine.fr
  
         LogLevel warn         LogLevel warn
-        #CustomLog ${APACHE_LOG_DIR}/searx.access.log combined 
         ErrorLog ${APACHE_LOG_DIR}/searx.error.log         ErrorLog ${APACHE_LOG_DIR}/searx.error.log
  
-        <IfModule mod_ssl.c> 
-                SSLEngine on 
-                SSLProxyEngine On 
-                ProxyRequests Off 
-                ProxyPreserveHost On 
-                SSLCertificateFile /etc/letsencrypt/live/nomdedomaine.fr/fullchain.pem 
-                SSLCertificateKeyFile /etc/letsencrypt/live/nomdedomaine.fr/privkey.pem 
-                AddDefaultCharset utf-8 
-                HostnameLookups off 
-                UseCanonicalName off 
-                ProxyBadHeader Ignore 
-                KeepAlive off 
-                Header set Content-Security-Policy "upgrade-insecure-requests; default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; form-action 'self'; font-src 'self'; frame-ancestors 'self'; base-uri 'self'; connect-src 'self' https://overpass-api.de; img-src *; frame-src https://www.youtube-nocookie.com https://player.vimeo.com https://www.dailymotion.com https://www.deezer.com https://www.mixcloud.com https://w.soundcloud.com https://embed.spotify.com; media-src *" 
-        </IfModule> 
  
-#       <FilesMatch \.xml$> +        SSLEngine on 
-#               SetEnv no-gzip 1 +        SSLProxyEngine On 
-#       </FilesMatch>+        ProxyRequests Off 
 +        ProxyPreserveHost On 
 +        SSLCertificateFile /etc/letsencrypt/live/domaine.fr/fullchain.pem 
 +        SSLCertificateKeyFile /etc/letsencrypt/live/domaine.fr/privkey.pem 
 +        AddDefaultCharset utf-8 
 +        HostnameLookups off 
 +        UseCanonicalName off 
 +        ProxyBadHeader Ignore 
 +        KeepAlive off
  
-        <FilesMatch "\.(cgi|shtml|phtml|php)$"+        ProxyPass / http://localhost:8085/ 
-                SSLOptions +StdEnvVars +        <Location /
-        </FilesMatch>+                ProxyPassReverse http://localhost:8085/ 
 +                Require all granted 
 +        </Location>
  
-        ProxyPass / http://127.0.0.1:4004/ +        # see limiter.py 
-        #ProxyPassReverse / http://localhost:4004/+        #RequestHeader set X-Real-IP %{REMOTE_ADDR}s 
 +        #RequestHeader append X-Forwarded-For %{REMOTE_ADDR}s
  
-        <Directory /usr/lib/cgi-bin> +        # intermediate configuration 
-                SSLOptions +StdEnvVars +        SSLProtocol             -all +TLSv1.2 +TLSv1.3 
-        </Directory>+        SSLOpenSSLConfCmd       Curves X25519:prime256v1:secp384r1 
 +        SSLCipherSuite          ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305 
 +        SSLHonorCipherOrder     off 
 +        SSLSessionTickets       off
  
-        BrowserMatch "MSIE [2-6]\ +        # enable HTTP/2, if available 
-        nokeepalive ssl-unclean-shutdown \ +        Protocols h2 http/1.1 
-        downgrade-1.0 force-response-1.0 + 
-        BrowserMatch "MSIE [17-9]ssl-unclean-shutdown+        # HTTP Strict Transport Security (mod_headers is required) (63072000 seconds) 
 +        Header always set Strict-Transport-Security "max-age=63072000" 
 + 
 +        <IfModule mod_headers.c> 
 +                Header set X-Content-Type-Options "nosniff" 
 +                Header set X-XSS-Protection "1; mode=block" 
 +                Header unset X-Powered-By 
 +                Header set Referrer-Policy: strict-origin-when-cross-origin 
 +                Header set Permissions-Policy "accelerometer=(),battery=(),fullscreen=(self),geolocation=(),camera=(),ambient-light-sensor=(self),autoplay=(self)" 
 +                Header set Content-Security-Policy "frame-ancestors 'self' *.domaine.fr; upgrade-insecure-requests; default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; form-action 'self'; font-src 'self'; frame-ancestors 'self'; base-uri 'self'; connect-src 'self' https://overpass-api.de; img-src *; frame-src https://www.youtube-nocookie.com https://player.vimeo.com https://www.dailymotion.com https://www.deezer.com https://www.mixcloud.com https://w.soundcloud.com https://embed.spotify.com; media-src *" 
 +        </IfModule>
  
 </VirtualHost> </VirtualHost>
  
-# modern configuration, tweak to your needs 
-SSLProtocol             all -SSLv3 -TLSv1 -TLSv1.1 
-SSLCipherSuite          ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256 
-SSLHonorCipherOrder     on 
-SSLCompression          off 
-SSLSessionTickets       off 
  
-# OCSP Stapling, only in httpd 2.3.3 and later 
-SSLUseStapling          on 
-SSLStaplingResponderTimeout 5 
-SSLStaplingReturnResponderErrors off 
-SSLStaplingCache        shmcb:/var/run/ocsp(128000) 
 </code> </code>
  
 Activez le fichier de configuration : Activez le fichier de configuration :
 <code bash>sudo a2ensite searx.nomdedomaine.fr.conf</code> <code bash>sudo a2ensite searx.nomdedomaine.fr.conf</code>
 +
 +Votre instance SearXNG est maintenant accessible à l'adresse searx.nomdedomaine.fr.
 +
 +
 +
  
  
  • serveur_hebergement/installer_une_instance_searx.1664732809.txt.gz
  • Dernière modification : 2023/08/08 14:01
  • (modification externe)