From 5f72ed29b291a9d61f56a160b9b3ee2f62ecc13d Mon Sep 17 00:00:00 2001 From: rafa_99 Date: Mon, 20 Jun 2022 00:17:18 +0100 Subject: Replaced SearX with SearXNG --- searx/README.md | 8 ---- searx/deploy | 47 ------------------ searx/nginx/pages/searx.conf | 6 --- searx/nginx/sites-available/server | 12 ----- searx/searx/settings.yml | 35 -------------- searx/uwsgi/apps-available/searx.ini | 87 ---------------------------------- searxng/README.md | 8 ++++ searxng/deploy | 48 +++++++++++++++++++ searxng/nginx/pages/searxng.conf | 6 +++ searxng/nginx/sites-available/server | 12 +++++ searxng/searxng/settings.yml | 61 ++++++++++++++++++++++++ searxng/uwsgi/apps-available/searx.ini | 87 ++++++++++++++++++++++++++++++++++ 12 files changed, 222 insertions(+), 195 deletions(-) delete mode 100644 searx/README.md delete mode 100755 searx/deploy delete mode 100644 searx/nginx/pages/searx.conf delete mode 100644 searx/nginx/sites-available/server delete mode 100644 searx/searx/settings.yml delete mode 100644 searx/uwsgi/apps-available/searx.ini create mode 100644 searxng/README.md create mode 100644 searxng/deploy create mode 100644 searxng/nginx/pages/searxng.conf create mode 100644 searxng/nginx/sites-available/server create mode 100644 searxng/searxng/settings.yml create mode 100644 searxng/uwsgi/apps-available/searx.ini diff --git a/searx/README.md b/searx/README.md deleted file mode 100644 index 6062098..0000000 --- a/searx/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# SearX -Self hosted SearX instance with default configurations. -To install just run the script using: - -`bash deploy` - -## About -All the configurations are implemented on local area network, to host searx just as localhost, remove your ip from `nginx/sites-available/searx`, under the server\_name section. diff --git a/searx/deploy b/searx/deploy deleted file mode 100755 index 998b393..0000000 --- a/searx/deploy +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -# Installing dependencies -sudo apt install -y python3-dev python3-babel python3-venv uwsgi uwsgi-plugin-python3 git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev shellcheck nginx - -# SearX -## Creating and setting up user -sudo -H useradd --shell /bin/bash --system \ - --home-dir "/usr/local/searx" \ - --comment 'Privacy-respecting metasearch engine' searx - -sudo -H mkdir "/usr/local/searx" -sudo -H chown -R "searx:searx" "/usr/local/searx" - -## Installing searx -sudo -H -u searx git clone "https://github.com/searx/searx.git" "/usr/local/searx/searx-src" -sudo -H -u searx python3 -m venv "/usr/local/searx/searx-pyenv" -echo "export SEARX_SETTINGS_PATH=\"/etc/searx/settings.yml\"" | sudo -H -u searx tee -a "/usr/local/searx/.profile" > /dev/null -echo ". /usr/local/searx/searx-pyenv/bin/activate" | sudo -H -u searx tee -a "/usr/local/searx/.profile" > /dev/null -sudo -H -u searx /usr/local/searx/searx-pyenv/bin/pip install -U pip setuptools wheel pyyaml -sudo -H -u searx /usr/local/searx/searx-pyenv/bin/pip install -e "/usr/local/searx/searx-src" - -## Configuring SearX -sudo -H cp -rf "searx/" "/etc/" -sudo -H sed -i s:YOURHOSTNAME:"$(hostname)":g /etc/searx/settings.yml - -# uwsgi -sudo -H cp -rf uwsgi/ /etc/ -sudo -H ln -s /etc/uwsgi/apps-available/searx.ini /etc/uwsgi/apps-enabled/ -sudo -H mkdir -p /run/uwsgi/app/searx/ -sudo -H chown -R searx:searx /run/uwsgi/app/searx/ - -# Nginx -sudo -H mkdir -p /etc/nginx/certs -sudo -H cp -rf nginx/ /etc/ -sudo -H ln -s /etc/nginx/sites-available/server /etc/nginx/sites-enabled/server -sudo -H sed -i s:"$(grep access_log /etc/nginx/nginx.conf | awk '{print $2}' )":\/dev\/null\;:g /etc/nginx/nginx.conf -sudo -H sed -i s:"$(grep error_log /etc/nginx/nginx.conf | awk '{print $2}' )":\/dev\/null\;:g /etc/nginx/nginx.conf - -# SSL -openssl req -x509 -out localhost.crt -keyout localhost.key -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' -extensions EXT -config <( printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth") -sudo mv localhost.* /etc/nginx/certs - -# Restarting services -sudo -H systemctl restart nginx -sudo -H systemctl enable nginx -sudo -H service uwsgi restart searx diff --git a/searx/nginx/pages/searx.conf b/searx/nginx/pages/searx.conf deleted file mode 100644 index 1c58d41..0000000 --- a/searx/nginx/pages/searx.conf +++ /dev/null @@ -1,6 +0,0 @@ -location /searx -{ - include uwsgi_params; - uwsgi_param SCRIPT_NAME /searx; - uwsgi_pass unix:/run/uwsgi/app/searx/socket; -} diff --git a/searx/nginx/sites-available/server b/searx/nginx/sites-available/server deleted file mode 100644 index ba75367..0000000 --- a/searx/nginx/sites-available/server +++ /dev/null @@ -1,12 +0,0 @@ -server -{ - server_name hostname.local; - - listen 443 ssl; - listen [::]:443 ssl; - - ssl_certificate /etc/nginx/certs/localhost.crt; - ssl_certificate_key /etc/nginx/certs/localhost.key; - - include pages/*.conf; -} diff --git a/searx/searx/settings.yml b/searx/searx/settings.yml deleted file mode 100644 index 351ed45..0000000 --- a/searx/searx/settings.yml +++ /dev/null @@ -1,35 +0,0 @@ -use_default_settings: True - -general: - debug : False # Debug mode, only for development - instance_name : "Sneed Searx" # displayed name - -search: - safe_search : 0 # Filter results. 0: None, 1: Moderate, 2: Strict - autocomplete : "duckduckgo" # Existing autocomplete backends: "dbpedia", "duckduckgo", "google", "startpage", "swisscows", "qwant", "wikipedia" - leave blank to turn it off by default - default_lang : "" # Default search language - leave blank to detect from browser information or use codes from 'languages.py' - -server: - port : 8888 - bind_address : "127.0.0.1" # address to listen on - secret_key : "" # change this! - base_url : "https://YOURHOSTNAME/searx" # Set custom base_url. Possible values: False or "https://your.custom.host/location/" - image_proxy : False # Proxying image results through searx - -ui: - static_path : "" # Custom static path - leave it blank if you didn't change - templates_path : "" # Custom templates path - leave it blank if you didn't change - default_theme : oscar # ui theme - default_locale : "" # Default interface locale - leave blank to detect from browser information or use codes from the 'locales' config section - theme_args : - oscar_style : logicodev-dark # default style of oscar - categories_order : - - general - - files - - images - - videos - - science - - it - - map - - music - - news diff --git a/searx/uwsgi/apps-available/searx.ini b/searx/uwsgi/apps-available/searx.ini deleted file mode 100644 index 430a455..0000000 --- a/searx/uwsgi/apps-available/searx.ini +++ /dev/null @@ -1,87 +0,0 @@ -[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 interpretor 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#plugin-http -# 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 diff --git a/searxng/README.md b/searxng/README.md new file mode 100644 index 0000000..a8f0c0f --- /dev/null +++ b/searxng/README.md @@ -0,0 +1,8 @@ +# SearXNG +Self hosted SearXNG instance with default configurations. +To install just run the script using: + +`bash deploy` + +## About +All the configurations are implemented on local area network, to host searx just as localhost, remove your ip from `nginx/sites-available/searx`, under the server\_name section. diff --git a/searxng/deploy b/searxng/deploy new file mode 100644 index 0000000..da076df --- /dev/null +++ b/searxng/deploy @@ -0,0 +1,48 @@ +#!/bin/bash + +# Installing dependencies +sudo apt install -y python3-dev python3-babel python3-venv uwsgi uwsgi-plugin-python3 git build-essential libxslt1-dev zlib1g-dev libffi-dev libssl-dev shellcheck nginx + +# SearX +## Creating and setting up user +sudo -H useradd --shell /bin/bash --system \ + --home-dir "/usr/local/searx" \ + --comment 'Privacy-respecting metasearch engine' searx + +sudo -H mkdir "/usr/local/searx" +sudo -H chown -R "searx:searx" "/usr/local/searx" + +## Installing searx +sudo -H -u searx git clone "https://github.com/searxng/searxng" "/usr/local/searx/searx-src" +sudo -H -u searx python3 -m venv "/usr/local/searx/searx-pyenv" +echo "export SEARX_SETTINGS_PATH=\"/etc/searxng/settings.yml\"" | sudo -H -u searx tee -a "/usr/local/searx/.profile" > /dev/null +echo ". /usr/local/searx/searx-pyenv/bin/activate" | sudo -H -u searx tee -a "/usr/local/searx/.profile" > /dev/null +sudo -H -u searx /usr/local/searx/searx-pyenv/bin/pip install -U pip setuptools wheel pyyaml +sudo -H -u searx /usr/local/searx/searx-pyenv/bin/pip install -e "/usr/local/searx/searx-src" + +## Configuring SearXNG +sudo -H cp -rf "searxng/" "/etc/" +sudo -H sed -i s:YOURHOSTNAME:"$(hostname)":g /etc/searx/settings.yml +sudo -H sed -i s:SERVERKEY:"$(openssl rand -hex 16)":g /etc/searx/settings.yml + +# uwsgi +sudo -H cp -rf uwsgi/ /etc/ +sudo -H ln -s /etc/uwsgi/apps-available/searx.ini /etc/uwsgi/apps-enabled/ +sudo -H mkdir -p /run/uwsgi/app/searx/ +sudo -H chown -R searx:searx /run/uwsgi/app/searx/ + +# Nginx +sudo -H mkdir -p /etc/nginx/certs +sudo -H cp -rf nginx/ /etc/ +sudo -H ln -s /etc/nginx/sites-available/server /etc/nginx/sites-enabled/server +sudo -H sed -i s:"$(grep access_log /etc/nginx/nginx.conf | awk '{print $2}' )":\/dev\/null\;:g /etc/nginx/nginx.conf +sudo -H sed -i s:"$(grep error_log /etc/nginx/nginx.conf | awk '{print $2}' )":\/dev\/null\;:g /etc/nginx/nginx.conf + +# SSL +openssl req -x509 -out localhost.crt -keyout localhost.key -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' -extensions EXT -config <( printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth") +sudo mv localhost.* /etc/nginx/certs + +# Restarting services +sudo -H systemctl restart nginx +sudo -H systemctl enable nginx +sudo -H service uwsgi restart searx diff --git a/searxng/nginx/pages/searxng.conf b/searxng/nginx/pages/searxng.conf new file mode 100644 index 0000000..461a6f0 --- /dev/null +++ b/searxng/nginx/pages/searxng.conf @@ -0,0 +1,6 @@ +location /searxng +{ + include uwsgi_params; + uwsgi_param SCRIPT_NAME /searx; + uwsgi_pass unix:/run/uwsgi/app/searx/socket; +} diff --git a/searxng/nginx/sites-available/server b/searxng/nginx/sites-available/server new file mode 100644 index 0000000..ba75367 --- /dev/null +++ b/searxng/nginx/sites-available/server @@ -0,0 +1,12 @@ +server +{ + server_name hostname.local; + + listen 443 ssl; + listen [::]:443 ssl; + + ssl_certificate /etc/nginx/certs/localhost.crt; + ssl_certificate_key /etc/nginx/certs/localhost.key; + + include pages/*.conf; +} diff --git a/searxng/searxng/settings.yml b/searxng/searxng/settings.yml new file mode 100644 index 0000000..f925ebb --- /dev/null +++ b/searxng/searxng/settings.yml @@ -0,0 +1,61 @@ +# SearXNG settings, before editing this file read: +# +# https://docs.searxng.org/admin/engines/settings.html + +use_default_settings: true + +general: + # Debug mode, only for development + debug: false + # change displayed name + instance_name: "SneedNG" + +search: + # Filter results. 0: None, 1: Moderate, 2: Strict + safe_search: 0 + # Existing autocomplete backends: "dbpedia", "duckduckgo", "google", + # "startpage", "swisscows", "qwant", "wikipedia" - leave blank to turn it off + # by default. + autocomplete: 'duckduckgo' + # Default search language - leave blank to detect from browser information or + # use codes from 'languages.py' + default_lang: '' + # remove format to deny access, use lower case. + formats: + - html + +server: + secret_key: "SERVERKEY" # change this! + base_url : "https://YOURHOSTNAME/searxng" + # Proxying image results through SearXNG + image_proxy: false + +ui: + default_locale: "" + query_in_title: false + default_theme: simple + theme_args: + simple_style: dark + +# result_proxy: +# url: http://127.0.0.1:3000/ +# key: !!binary "your_morty_proxy_key" + +# plugins: +# - only_show_green_results + +# engines: +# +# - name: duckduckgo +# disabled: false +# +# - name: fdroid +# disabled: false +# +# - name: apk mirror +# disabled: false +# +# - name: mediathekviewweb +# engine: mediathekviewweb +# shortcut: mvw +# categories: general diff --git a/searxng/uwsgi/apps-available/searx.ini b/searxng/uwsgi/apps-available/searx.ini new file mode 100644 index 0000000..31e4bd6 --- /dev/null +++ b/searxng/uwsgi/apps-available/searx.ini @@ -0,0 +1,87 @@ +[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/searxng/settings.yml + +# disable logging for privacy +disable-logging = true + +# The right granted on the created socket +chmod-socket = 666 + +# Plugin to use and interpretor 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#plugin-http +# 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 -- cgit v1.2.3