Privacy Tools #SearXNG#private search#self-hosted

SearXNG: Self-Hosted Private Search Engine with Docker

Set up SearXNG, a self-hosted metasearch engine, using Docker to search the web privately without tracking, profiling, or ads.

7 min read

SearXNG is an open-source metasearch engine that aggregates results from Google, Bing, DuckDuckGo, and dozens of other sources without sending your query to any of them with identifying information. When you self-host SearXNG, your searches are made from your server’s IP address — not yours — and no search history is stored. This guide walks through setting up SearXNG on a home server or VPS using Docker Compose.

Why SearXNG?

Public SearXNG instances exist (searx.space lists them), but they may be operated by unknown parties, could be logging, and may have uptime issues. Self-hosting gives you:

  • Full control — you know exactly what’s logged (nothing, if configured correctly)
  • Your own IP — if hosted on a VPS, searches appear to come from that IP rather than your home
  • Customization — configure which engines to use, preferences, and appearance
  • No rate limiting — public instances often get blocked by search engines due to traffic volume

Prerequisites

  • A VPS or home server running Ubuntu 22.04/Debian 12 (minimum 512 MB RAM)
  • Docker and Docker Compose installed
  • A domain name (optional but recommended for HTTPS)

Install Docker

curl -fsSL https://get.docker.com | bash
sudo usermod -aG docker $USER
newgrp docker

Verify:

docker --version
docker compose version

Setting Up SearXNG with Docker Compose

Create a directory for SearXNG:

mkdir -p ~/searxng && cd ~/searxng

Create a docker-compose.yml file:

version: "3.7"

services:
  redis:
    image: "redis:alpine"
    command: redis-server --save "" --appendonly "no"
    networks:
      - searxng
    tmpfs:
      - /var/lib/redis
    cap_drop:
      - ALL
    cap_add:
      - SETGID
      - SETUID
      - DAC_OVERRIDE

  searxng:
    image: searxng/searxng:latest
    networks:
      - searxng
    ports:
      - "127.0.0.1:8080:8080"
    volumes:
      - ./searxng:/etc/searxng:rw
    environment:
      - SEARXNG_BASE_URL=https://yourdomain.com/
    cap_drop:
      - ALL
    cap_add:
      - CHOWN
      - SETGID
      - SETUID
    logging:
      driver: "json-file"
      options:
        max-size: "1m"
        max-file: "1"

networks:
  searxng:
    ipam:
      driver: default

Replace https://yourdomain.com/ with your actual domain or http://localhost:8080/ for local-only access.

Configuring SearXNG

Generate the required secret key and create the config directory:

mkdir -p searxng
openssl rand -hex 32 > searxng/secret_key

Create searxng/settings.yml:

use_default_settings: true

server:
  secret_key: !include /etc/searxng/secret_key
  limiter: true
  image_proxy: true
  port: 8080
  bind_address: "0.0.0.0"

search:
  safe_search: 0
  autocomplete: "google"
  default_lang: "auto"

ui:
  static_use_hash: true
  default_locale: ""
  query_in_title: false
  infinite_scroll: false
  center_alignment: false
  default_theme: simple

outgoing:
  request_timeout: 3.0
  useragent_suffix: ""
  pool_connections: 100
  pool_maxsize: 20

Starting SearXNG

docker compose up -d

Check that it’s running:

docker compose ps
docker compose logs searxng

Access it locally at http://localhost:8080.

Setting Up HTTPS with Nginx and Certbot

For a publicly accessible instance with HTTPS, install Nginx and Certbot:

sudo apt install nginx certbot python3-certbot-nginx -y

Create an Nginx config at /etc/nginx/sites-available/searxng:

server {
    listen 80;
    server_name yourdomain.com;

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Enable the site and obtain a certificate:

sudo ln -s /etc/nginx/sites-available/searxng /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
sudo certbot --nginx -d yourdomain.com

Certbot automatically modifies your Nginx config to add SSL. SearXNG is now accessible at https://yourdomain.com.

Configuring Engines

SearXNG’s power is in which engines it queries. Edit searxng/settings.yml to enable or disable specific search engines:

engines:
  - name: google
    engine: google
    shortcut: g
    disabled: false
  - name: bing
    engine: bing
    shortcut: bi
    disabled: false
  - name: duckduckgo
    engine: duckduckgo
    shortcut: ddg
    disabled: false
  - name: startpage
    engine: startpage
    shortcut: sp
    disabled: false

Set disabled: true for engines you don’t want to use. After changing settings:

docker compose restart searxng

Setting SearXNG as Your Default Browser Search Engine

In Firefox:

  1. Navigate to your SearXNG URL
  2. Click the address bar — a magnifying glass icon with a ”+” appears
  3. Click Add “SearXNG” to add it as a search engine
  4. Go to Settings → Search → set SearXNG as the default

In Chrome, you need to use a browser extension (like “Add custom search engine”) to add a non-Chrome-approved search engine as default.

Privacy Hardening

For maximum privacy in settings.yml:

server:
  limiter: true
  
general:
  debug: false

search:
  ban_time_on_fail: 5
  max_ban_time_on_fail: 120

Also consider:

  • Never log searches: The default Docker setup doesn’t persist logs to disk
  • Restrict access: Use HTTP Basic Auth in Nginx to limit access to yourself and trusted users
  • Keep updated: docker compose pull && docker compose up -d updates to the latest image

SearXNG is one of the most practical privacy tools you can self-host — it replaces a daily-use service (web search) with one that’s entirely under your control.

#privacy #Docker #self-hosted #private search #SearXNG