Ceci est une ancienne révision du document !
Installer une instance Searx
Présentation de Searx
Préparation
Installez les dépendances :
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
Créez un utilisateur searx :
sudo useradd --shell /bin/bash --system -ome-dir "/usr/local/searx" --comment 'Privacy-respecting metasearch engine' searx
Créez le répertoire home :
sudo mkdir "/usr/local/searx"
Modifiez le propriétaire du répertoire home :
sudo chown -R "searx:searx" "/usr/local/searx"
Installation de Searx
Connectez-vous avec l'utilisateur searx :
sudo -u searx -i
Récupérez les sources de Searx :
git clone "https://github.com/searx/searx.git" "/usr/local/searx/searx-src"
Créez l'environnement Python :
python3 -m venv "/usr/local/searx/searx-pyenv"
Activez-le à chaque connexion :
echo ". /usr/local/searx/searx-pyenv/bin/activate" >> "/usr/local/searx/.profile"
Déconnectez vous avec la commande
exit
Connectez-vous de nouveau avec l'utilisateur searx :
sudo -u searx -i
Mettre à jour les modules nécessaires :
pip install -U pip pip install -U setuptools pip install -U wheel pip install -U pyyaml
Lancez l'installation :
cd "/usr/local/searx/searx-src" pip install -e .
Configuration
Dans un autre terminal, copiez le fichier de configuration par défaut :
sudo mkdir -p "/etc/searx" sudo cp "/usr/local/searx/searx-src/utils/templates/etc/searx/use_default_settings.yml" "/etc/searx/settings.yml"
Ouvrez le fichier /etc/searx/settings.yml et remplacez la valeur de la secret_key par une suite de chiffres et de lettres.
Pour vérifiez que Searx se lance sans problème, activez le debug :
sudo sed -i -e "s/debug : False/debug : True/g" "/etc/searx/settings.yml"
Connectez-vous de nouveau avec l'utilisateur searx si vous vous êtes déconnectés :
sudo -u searx -i
Puis lancez searx :
cd /usr/local/searx/searx-src export SEARX_SETTINGS_PATH="/etc/searx/settings.yml" python searx/webapp.py
Désactivez le mode debug :
sudo sed -i -e "s/debug : True/debug : False/g" "/etc/searx/settings.yml"
uWSGI
uWSGI va nous permettre de démarrer l'instance Searx.
Créez le fichier de configuration pour uWSGI :
sudo nano /etc/uwsgi/apps-available/searx.ini
Collez-y les lignes suivantes :
[uwsgi] # 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
Activez le lancement au démarrage de Searx :
sudo ln -s /etc/uwsgi/apps-available/searx.ini /etc/uwsgi/apps-enabled/
Démarrez Searx :
sudo service uwsgi start searx
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)
Activez les modules Apache2 nécessaires :
sudo a2enmod headers proxy proxy_http
Créez le fichier de config Apache2 :
sudo nano /etc/apache2/sites-available/searx.domaine.fr.conf
Copiez-y les lignes suivantes (remplacez le noom de domaine par le votre ainsi que l'emplacement des fichiers SSL) :
<VirtualHost *:80> ServerName searx.nomdedomaine.fr ServerAdmin fate@nomdedomaine.fr Redirect / https://searx.nomdedomaine.fr/ </VirtualHost> LogLevel warn #CustomLog ${APACHE_LOG_DIR}/searx.access.log combined 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$> # SetEnv no-gzip 1 # </FilesMatch> <FilesMatch "\.(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars </FilesMatch> ProxyPass / http://127.0.0.1:4004/ #ProxyPassReverse / http://localhost:4004/ <Directory /usr/lib/cgi-bin> SSLOptions +StdEnvVars </Directory> BrowserMatch "MSIE [2-6]" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0 BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown </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)