Skip to content

SearXNG

SearXNG is a free internet metasearch engine which aggregates results from more than 70 search services.

SearXNG Screenshot

Users are neither tracked nor profiled. You can use one of the 100+ public instances (including ours), or (and really, this is why you're here, right?) you can run your own instance

How does SearXNG protect my privacy?

From the docs: SearXNG protects the privacy of its users in multiple ways regardless of the type of the instance (private, public). Removal of private data from search requests comes in three forms:

✅ removal of private data from requests going to search services
✅ not forwarding anything from a third party services through search services (e.g. advertisement)
✅ removal of private data from requests going to the result pages

Removing private data means not sending cookies to external search engines and generating a random browser profile for every request. Thus, it does not matter if a public or private instance handles the request, because it is anonymized in both cases. IP addresses will be the IP of the instance. But SearXNG can be configured to use proxy or Tor. Result proxy is supported, too.

SearXNG does not serve ads or tracking content unlike most search services. So private data is not forwarded to third parties who might monetize it. Besides protecting users from search services, both referring page and search query are hidden from visited result pages.

SearXNG Requirements

Ingredients

Already deployed:

Related:

Preparation

Setup SearXNG data directory

First we create a directory to hold the files (really just the persistence of settings) which searxng will create:

mkdir /var/data/searxng

Setup SearXNG environment

Create /var/data/config/searxng/searxng.env something like the example below..

/var/data/config/searxng/searxng.env
BIND_ADDRESS=0.0.0.0:8080
BASE_URL=https://searxng.example.com/
INSTANCE_NAME="example.com's searxng instance"
AUTOCOMPLETE="false"

SearXNG Docker Swarm config

Create a docker swarm config file in docker-compose syntax (v3), something like the example below:

Fast-track with premix! 🚀

I automatically and instantly share (with my sponsors) a private "premix" git repository, which includes necessary docker-compose and env files for all published recipes. This means that sponsors can launch any recipe with just a git pull and a docker stack deploy 👍.

🚀 Update: Premix now includes an ansible playbook, so that sponsors can deploy an entire stack + recipes, with a single ansible command! (more here)

version: "3.2"

services:

  searxng:
    image: searxng/searxng:latest
    env_file: /var/data/config/searxng/searxng.env
    volumes:
      - /var/data/searxng:/etc/searxng:rw

    deploy:
      replicas: 1
      labels:
        # traefik
        - traefik.enable=true
        - traefik.docker.network=traefik_public

        # traefikv2
        - "traefik.http.routers.searxng.rule=Host(`searxng.example.com`)"
        - "traefik.http.routers.searxng.entrypoints=https"
        - "traefik.http.services.searxng.loadbalancer.server.port=8080"

    networks:
      - traefik_public

networks:
  traefik_public:
    external: true

Serving

Deploy SearXNG!

Deploy SearXNG by running docker stack deploy searxng -c <path -to-docker-compose.yml>

Now browse to the URL you specified in BASE_URL (which should match your traefik labels in the docker-compose file), and you should be presented with your very own SearXNG interface!

Customize SearXNG

Take a look in /var/data/searxng, and note that a settings.yml file has been created. You can customize your searXNG instance by editing settings.yml, making changes, and then restarting the stack with docker service update searxng --force.

Here are some useful customizations I've included in mine:

Redirect YouTube to Invidious

I set the following, to automatically redirect any YouTube search results to my Individous instance:

hostname_replace:
  '(.*\.)?youtube\.com$': 'in.fnky.nz'
  '(.*\.)?youtu\.be$': 'in.fnky.nz'

Search YouTube via Invidious

Likewise, the following addition to the engines section allows my to perform an Individous search directly from SearXNG:

  - name: invidious
    engine: invidious
    base_url:
      - https://in.fnky.nz
    shortcut: in
    timeout: 3.0
    disabled: false

Get SearXNG search results as RSS

It's not enabled by default, but by adding rss to the list of search formats (json is an option too), you can get search results via RSS:

search:
  formats:
    - html
    - rss

Who would need search results via RSS?

For one, anyone who wanted to build their own crude "Google Alerts" - you'd perform the search you wanted to monitor, click the RSS download link (or just append &format=rss to the search URL), and add this link to your RSS reader. Any changes in the result will be reflected as a new RSS entry1!

Chef's notes 📓


  1. Combine SearXNG's RSS results with Huggin for a more feature-full alternative to Google Alerts! 💪 

Tip your waiter (sponsor) 👏

Did you receive excellent service? Want to compliment the chef? (..and support development of current and future recipes!) Sponsor me on Github / Ko-Fi / Patreon, or see the contribute page for more (free or paid) ways to say thank you! 👏

Employ your chef (engage) 🤝

Is this too much of a geeky PITA? Do you just want results, stat? I do this for a living - I'm a full-time Kubernetes contractor, providing consulting and engineering expertise to businesses needing short-term, short-notice support in the cloud-native space, including AWS/Azure/GKE, Kubernetes, CI/CD and automation.

Learn more about working with me here.

Flirt with waiter (subscribe) 💌

Want to know now when this recipe gets updated, or when future recipes are added? Subscribe to the RSS feed, or leave your email address below, and we'll keep you updated.

Your comments? 💬