levant's cyberspace

/blogposts/20220828.html

MENU

self hosting a searxng instance


"searxng (fork of searx) is a free internet metasearch engine which aggregates results from various search services and databases. users are neither tracked nor profiled."

searxng works this way: it queries various search engines (which you can enable or disable yourself if you self host) and then it returns you everything that it found.

you might think: if it queries many search engines then those search engines will see what i searched for!

but it's not true, searxng builds a random search profile which has nothing to do with you and then queries the search engines.
and that random profile is generated for every search.
it's also ad free.

i strayed away from public instances because using one would mean trusting whoever is running that instance.
and you can never know if that instance logs your requests or even sell them to third parties.

i used a basic linux installation for this, just to practice a bit before running it on my main rig.

the documentation has a handy little installation script which i definitely used because i am way too lazy to complete the installation by hand.

the server i used was nginx. mind that on arch linux the mime.types file in /etc/nginx might be missing, just run

sudo pacman -S mime-types

after a big of messing around because i was dumb enough to mess up the permissions of the script, i managed to get a basic instance up and running.

now, searxng can be configured in various ways, for example it gives you the opportunity to be able to redirect certain urls to others (for example redirecting youtube to a privacy friendly frontend, like invidious).

it also gives you the opportunity to query search engines like ahmia, which is used to browse .onion sites. you need the tor proxy for this, in arch linux you can run

sudo pacman -S tor

and then

sudo systemctl enable tor && sudo systemctl start tor

i have modified the settings file, which in my case was located in /etc/searxng/settings.yml to be able to query ahmia and also redirect some sites to a more privacy respecting front end.

# for the redirects the hostname replace plugin must be enabled
# configuration below

enabled_plugins:
  - 'Hash plugin'
  - 'Search on category select'
  - 'Self Informations'
  - 'Tracker URL remover'
  - 'Ahmia blacklist'
  - 'Hostname replace'
  - 'Tor check plugin'

hostname_replace:
  '(.*\.)?youtube\.com$': 'yt.beparanoid.de'
  '(.*\.)?youtu\.be$': 'yt.beparanoid.de'
  '(.*\.)?youtube-noocookie\.com$': 'yt.beparanoid.de'
  '(.*\.)?reddit\.com$': 'reddit.beparanoid.de'
  '(.*\.)?redd\.it$': 'reddit.beparanoid.de'
  '(www\.)?twitter\.com$': 'nitter.snopyta.com'

and as an optional, i also made my instance query ahmia as well.

categories_as_tabs:
  general:
  images:
  videos:
  news:
  map:
  music:
  it:
  science:
  files:
  social media:
  onions: # add the onions category

- name: ahmia
  engine: ahmia
  using_tor_proxy: true
  proxies:
   all://:
    - socks5h://127.0.0.1:9050
  extra_proxy_timeout: 30.0
  categories: onions
  enable_http: true
  shortcut: ah