SearXNG – Your Very Own Self-hosted Search Engine

Are you tired of using Google search, especially at how it comes with plenty of advertisement, and tracks you and your searches? The good news is, you can use SearXNG to create your very own search engine that aggregates results from up to 215 search services, while staying anonymous and retain your privacy.

Features

  • self-hosted
  • No advertisements
  • no user tracking / no profiling
  • script & cookies are optional
  • secure, encrypted connections
  • 215 search engines
  • 58 translations
  • easy integration of search engines

Why Self-host Your Own Search Engine?

When you use a public search engine like Google, Bing, or DuckDuckGo, you are subjected to their terms and conditions. Most of them show advertisements on their sites (that is how they make money), track your search data and create a profile of you in your browser. They will say that it is meant to give you a better search results, but at the expense of your privacy.

When you host your own search engine using SearXNG, you can get your search results from several search engines and your personal data is not sent to the search services, so your presence is anonymized.

Installation

The fastest and easiest way to set up SearXNG is via Docker.

Create a folder for searxng:

mkdir searxng
cd searxng

Clone the searxng-docker git repository:

git clone https://github.com/searxng/searxng-docker.git
cd searxng-docker

Open the docker-compose.yml file

nano docker-compose.yml

You should see something similar to this:

services:
caddy
:
container_name
: caddy
image
: docker.io/library/caddy:2-alpine
network_mode
: host
restart
: unless-stopped
volumes
:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- caddy-data:/data:rw
- caddy-config:/config:rw
environment
:
- SEARXNG_HOSTNAME=${SEARXNG_HOSTNAME:-http://localhost}
- SEARXNG_TLS=${LETSENCRYPT_EMAIL:-internal}
cap_drop
:
- ALL
cap_add
:
- NET_BIND_SERVICE
logging
:
driver
: "json-file"
options
:
max-size
: "1m"
max-file
: "1"

redis
:
container_name
: redis
image
: docker.io/valkey/valkey:8-alpine
command
: valkey-server --save 30 1 --loglevel warning
restart
: unless-stopped
networks
:
- searxng
volumes
:
- valkey-data2:/data
cap_drop
:
- ALL
cap_add
:
- SETGID
- SETUID
- DAC_OVERRIDE
logging
:
driver
: "json-file"
options
:
max-size
: "1m"
max-file
: "1"

searxng
:
container_name
: searxng
image
: docker.io/searxng/searxng:latest
restart
: unless-stopped
networks
:
- searxng
ports
:
- "8080:8080"
volumes
:
- ./searxng:/etc/searxng:rw
environment
:
- SEARXNG_BASE_URL=https://${SEARXNG_HOSTNAME:-localhost}/
- UWSGI_WORKERS=${SEARXNG_UWSGI_WORKERS:-4}
- UWSGI_THREADS=${SEARXNG_UWSGI_THREADS:-4}
cap_drop
:
- ALL
cap_add
:
- CHOWN
- SETGID
- SETUID
logging
:
driver
: "json-file"
options
:
max-size
: "1m"
max-file
: "1"

networks
:
searxng
:

volumes
:
caddy-data
:
caddy-config
:
valkey-data2:

There are a few things you can customize here:

  • The docker compose file is bundled with a Caddy server. If your homelab is already running a reverse proxy server, or using Cloudflare Tunnel, then you can remove the whole Caddy section.
  • In the “Searxng” section, you can change the port mapping to another port in your homelab
  • For the first run, remove the cap_drop: - ALL line from the docker-compose file. Once you have set it up, restore the cap_drop: - ALL line in the docker-compose file, and restart the docker container.

Once you have made the changes, save and exit the docker-compose.yml file. Next, open the .env file:

nano .env

You should see something like this:

# By default listen on https://localhost
# To change this:
# * uncomment SEARXNG_HOSTNAME, and replace <host> by the SearXNG hostname
# * uncomment LETSENCRYPT_EMAIL, and replace <email> by your email (require to create a Let's Encrypt certificate)

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

# Optional:
# If you run a very small or a very large instance, you might want to change the amount of used uwsgi workers and threads per worker
# More workers (= processes) means that more search requests can be handled at the same time, but it also causes more resource usage

# SEARXNG_UWSGI_WORKERS=4
# SEARXNG_UWSGI_THREADS=4

Remove the # from the SEARXNG_HOSTNAME=<host> line and change the <host> to your hostname.

If you need a LetsEncrypt SSL certificate, uncomment the LETSENCRYPT_EMAIL line and insert your LetsEncrypt’s email address.

Save and exit the file.

Run the following command to generate a secret key for your SearXNG instance:

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

Lastly, start your SearXNG instance:

docker compose up -d

Usage

Once you have started the docker instance, you can go to http://127.0.0.1:8080 to access your very own SearXNG private instance. If you have changed the port, or set up a custom hostname in Cloudflare Tunnel, then you can access SearXNG via your custom URL.

Searxng Home Page

There is only a search bar in the center of the page, so there is nothing else to do but search.

Searxng Search Results

You can see that the results are aggregated from various search engines. The sources are cited at the bottom right of each result, so you know where it came from.

Like various search engines, you can switch between different categories like “General”, “Images”, “Videos”, “News”, etc.

To customize SearXNG, click on “Preferences”.

Searxng Preferences General Tab

The “General” tab is where you can configure the behavior of the search engine. You can set the search language, whether it should autocomplete, enable SafeSearch, etc.

Searxng Preferences User Interface Tab

The “User Interface” tab allows you to customize the look and feel of the search page, including the theme, center align the search results, open results in new tabs, infinite scrolling, etc.

Searxng Preferences Privacy Tab

If you are concerned about your privacy, set the HTTP method to “POST” in the “Privacy” tab, and enable the “Tracker URL remover” option.

Searxng Preferences Engines Tab

The “Engines” tab is probably the most important section because it allows you to select which search engines you want to use to fetch the search results. The list is long (a total of 215 search engines), but you don’t have to select them all. You can choose the ones you often use (or the ones whose results you trust the most).

Final Thoughts

SearXNG is an easy to install and use meta-search engine. You can get it running in just 5 minutes. There is really nothing to stop you from protecting your privacy and prevent others from tracking you.

Be the first to comment! Get the discussion going.

Leave a Comment

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.