logo

dmpop

Aircraft photography, spaghetti code, half-baked thoughts

Guestbook Reads
Currently reading: Gli occhi di Venezia, Alessandro Barbero


How to self-host a search engine in 15 minutes

After trialing SearXNG for a while, I decided to host my own SearXNG instance. In case you are not familiar with SearXNG, it's a metasearch engine that pulls search results from multiple sources, such as Google, Qwant, Brave Search, DuckDuckGo, etc. It does that while scrubbing off tracking, profiling, and other surveillance capitalism cruft.

Thanks to the Docker magic, deploying SearXNG is a fairly straightforward process. Assuming you don't have a Debian-based server or Virtual Private Server (VPS) ready, you need to do some preparatory work, though.

  1. Get a VPS. I opted for the VPS Linux XS from ionos.de that costs €1/month (plus €10 one-time setup fee).
  2. Install Debian 12 on the VPS.
  3. Register a domain name, and assign it to the VPS. I used Namecheap to buy a super cheap .lol domain.

Before you can deploy SearXNG on your shiny new VPS, install Docker and clone SearXNG Git repository. To do this, log in to the VPS as root (or log in as a regular user and become root), and run the following commands:

apt update
apt upgrade
apt install apt-transport-https ca-certificates curl gnupg git fail2ban
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/debian bookworm stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
cd /usr/local
git clone https://github.com/searxng/searxng-docker.git
cd searxng-docker

Use the nano .env command to open the .env file for editing, and locate the following lines:

# SEARXNG_HOSTNAME=<host>
# LETSENCRYPT_EMAIL=<email>

Uncomment both lines and replace <host> with the actual domain name and <email> with a valid email address. The result should look as follows:

SEARXNG_HOSTNAME=domain.tld
LETSENCRYPT_EMAIL=me@domain.tld

Save the changes and close the file.

Generate a secret key:

sed -i "s|ultrasecretkey|$(openssl rand -hex 32)|g" searxng/settings.yml

And finally, start a SearXNG Docker container:

docker compose up -d

Point the browser to https://domain.tld (replace domain.tld with the domain name of the VPS), and you should see SearXNG in all its bare-bones beauty.

Source: searxng-docker


Published: 2024-10-10Reads: 1500
Back
dmpop

dmpop

Linux user, amateur photographer, aviation enthusiast, clueless developer of ADS-B station, Pellicola and Tinble, author of a bunch of books. I can mix a decent Negroni, too. You can reach me at me@dmpop.xyz