From 6274a54746b4444f8850aecea0cb0734c6bdc29c Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 30 Jan 2020 19:55:51 +0100 Subject: [PATCH] utils/searx.sh & filtron.sh: misc changes from first tests (WIP) Signed-off-by: Markus Heiser --- utils/filtron.sh | 10 +++++++++- utils/lib.sh | 6 +++++- utils/searx.sh | 3 +++ .../etc/apache2/sites-available/searx.conf:filtron | 14 +++++++++++++- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/utils/filtron.sh b/utils/filtron.sh index 6ea001d42..d6e5b6a1b 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -11,6 +11,10 @@ source_dot_config # config # ---------------------------------------------------------------------------- +FILTRON_URL_PATH="${FILTRON_URL_PATH:-$(echo "${PUBLIC_URL}" \ +| sed -e 's,^.*://[^/]*\(/.*\),\1,g')}" +[[ "${FILTRON_URL_PATH}" == "${PUBLIC_URL}" ]] && FILTRON_URL_PATH=/ + FILTRON_ETC="/etc/filtron" FILTRON_RULES="$FILTRON_ETC/rules.json" @@ -192,7 +196,9 @@ installations that were installed with this script." wait_key remove_user rm -r "$FILTRON_ETC" 2>&1 | prefix_stdout - wait_key + if service_is_available "${PUBLIC_URL}"; then + MSG="** Don't forget to remove your public site! (${PUBLIC_URL}) **" wait_key 10 + fi } install_service() { @@ -329,6 +335,7 @@ inspect_service() { sourced ${DOT_CONFIG#"$REPO_ROOT/"} : PUBLIC_URL : ${PUBLIC_URL} + FILTRON_URL_PATH : ${FILTRON_URL_PATH} FILTRON_API : ${FILTRON_API} FILTRON_LISTEN : ${FILTRON_LISTEN} FILTRON_TARGET : ${FILTRON_TARGET} @@ -395,6 +402,7 @@ This installs a reverse proxy (ProxyPass) into apache site (${APACHE_FILTRON_SIT return fi + a2enmod headers a2enmod proxy a2enmod proxy_http diff --git a/utils/lib.sh b/utils/lib.sh index e2bcd8e9d..0586b2575 100755 --- a/utils/lib.sh +++ b/utils/lib.sh @@ -121,10 +121,11 @@ wait_key(){ clean_stdin local _t=$1 + local msg="${MSG:-** press any [KEY] to continue **}" [[ ! -z $FORCE_TIMEOUT ]] && _t=$FORCE_TIMEOUT [[ ! -z $_t ]] && _t="-t $_t" # shellcheck disable=SC2086 - read -r -s -n1 $_t -p "** press any [KEY] to continue **" + read -r -s -n1 $_t -p "$msg" echo clean_stdin } @@ -436,6 +437,9 @@ service_is_available() { if [[ $exit_val = 0 ]]; then info_msg "got $http_code from ${URL}" fi + case "$http_code" in + 404|410|423) exit_val=$http_code;; + esac return $exit_val } diff --git a/utils/searx.sh b/utils/searx.sh index a352c0439..b036541cf 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -275,6 +275,9 @@ installations that were installed with this script." remove_searx_uwsgi wait_key remove_user + if service_is_available "${PUBLIC_URL}"; then + MSG="** Don't forgett to remove your public site! (${PUBLIC_URL}) **" wait_key 10 + fi } user_is_available() { diff --git a/utils/templates/etc/apache2/sites-available/searx.conf:filtron b/utils/templates/etc/apache2/sites-available/searx.conf:filtron index d2f5431a7..f0914e9f9 100644 --- a/utils/templates/etc/apache2/sites-available/searx.conf:filtron +++ b/utils/templates/etc/apache2/sites-available/searx.conf:filtron @@ -1,3 +1,15 @@ # -*- coding: utf-8; mode: apache -*- -ProxyPass "/searx" "http://127.0.0.1:4004/" + + + Require all granted + Allow from all + + Order deny,allow + Deny from all + #Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1 + + ProxyPass "http://127.0.0.1:4004" + RequestHeader set "X-Script-Name" "${FILTRON_URL_PATH}" + +