Hrant's corner

Self-hosting SearXNG with Docker, Nginx, and SSL

SearXNG is a powerful metasearch engine that lets you search the web without leaking your data to Big Tech. Here’s how I self-hosted it at searx.hrant.am using Docker, Nginx, and Let’s Encrypt SSL — all on a Debian server I already use for my Hugo blog.

Why SearXNG?

  • Open source and privacy-respecting
  • Fully customizable
  • Runs on ARM or x86
  • Works great behind a reverse proxy

🧱 Prerequisites

  • A Debian server (mine is ARM-based)
  • Docker and Docker Compose
  • Nginx
  • A domain/subdomain (I used searx.hrant.am)
  • Certbot for SSL

📦 Step 1: Run SearXNG with Docker

Create a new directory and a docker-compose.yml:

mkdir ~/searxng && cd ~/searxng

Create the docker-compose.yml file:

version: "3"

services:
  searxng:
    image: searxng/searxng:latest
    container_name: searxng
    ports:
      - "8888:8080"
    restart: unless-stopped
    environment:
      - BASE_URL=https://searx.hrant.am/
      - INSTANCE_NAME=SearXNG
    volumes:
      - ./searxng-settings:/etc/searxng

Then run the following command to start SearXNG:
docker-compose up -d

This will spin up the service at http://localhost:8888. 🌐 Step 2: Configure Nginx Reverse Proxy

Now that SearXNG is running, we need to configure Nginx to reverse proxy it to a subdomain. Create a new Nginx site config:

sudo nano /etc/nginx/sites-available/searxng
Paste the following configuration:

server {
    listen 80;
    server_name searx.hrant.am;

    location / {
        proxy_pass http://localhost:8888;
        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 new site and reload Nginx:

sudo ln -s /etc/nginx/sites-available/searxng /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

🔐 Step 3: Add SSL with Certbot

Now, let’s secure the connection with SSL using Certbot:

sudo certbot --nginx -d searx.hrant.am

Once complete, your SearXNG instance will be available securely at: 👉 https://searx.hrant.am

✅ Done

You now have your own private, ad-free, metasearch engine running on your server. You can further customize SearXNG with your own search engines, themes, and other tweaks.

If you’d like to add authentication or restrict access, I will cover that in a follow-up post.

Thanks for reading! Check out the engine in action at searx.hrant.am.