SearXNG is a free, open-source metasearch engine that gives you private search results without tracking. It can also work as a JSON search backend for AI agents and automation tools. In this guide, you will set up a self-host SearXNG Docker instance with Redis, Nginx, TLS, and a secure public JSON API.
If you need a reliable server to run this setup, you can use a lightweight Linux VPS from PerLod.
What You Need Before Starting Self-Host SearXNG Docker
To self-host SearXNG Docker instance, you need:
A Linux VPS running Ubuntu 22.04 or 24.04.
A domain name with an A record pointing to your server's IP.
Root or sudo access via SSH.
Docker and Docker Compose are installed.
Ports 80 and 443 are open on your firewall.
Verify that Docker and Docker Compose are working correctly:
Bash
docker--versiondockercomposeversion
Once everything is ready, proceed to the following steps to self-host SearXNG Docker instance.
Step 1. Create the SearXNG Project Directory
To keep everything organized, create the project directory:
Bash
mkdir-p~/searxng/searxngcd~/searxng
This gives you:
~/searxng/: The project root where your docker-compose.yml lives.
~/searxng/searxng/: The config folder is mounted into the container.
Step 2. Create SearXNG Docker Compose File
This is the core of the self-host SearXNG Docker setup. Use your desired text editor to create the file:
This is the best way to start a self-host SearXNG Docker setup for testing. SearXNG supports limiter: false and public_instance: false, and that avoids local testing problems while you check that the app is working first.
The formats list must include json if you want the API to work. If json is not enabled, requests that use ?format=json can fail.
The cache setting is now uses valkey.url, because current SearXNG versions warn that redis.url is deprecated and valkey.url should be used instead.
Step 4. Configure the SearXNG Rate Limiter
When limiter: true is set in settings.yml, SearXNG looks for a limiter.toml file. You can create it:
You will not use the limiter right away, but it is good to create the file now. Later, when you change the self-host SearXNG Docker instance from local testing to public API use, this file will help with bot protection and request control.
link_token = true helps block bad bots. Requests without a valid token can be limited or denied.
The trusted_proxies list tells SearXNG to trust your reverse proxy and use the real client IP from X-Forwarded-For.
Step 5. Start the SearXNG Containers
Now you can start your containers with the commands below:
Bash
cd~/searxngdockercomposeup-d
Check that both containers started:
Bash
dockercomposepsdockercomposelogs-fsearxng
If the service starts and the worker comes up, your self-host SearXNG Docker stack is running locally.
Step 6. Configure Nginx with TLS and Rate Limiting
SearXNG’s limiter is meant for protecting public instances, and it relies on the cache backend and proxy-aware client IP handling.
Restart the containers after the change:
Bash
cd~/searxngdockercomposedowndockercomposeup-d
This makes your self-host SearXNG Docker setup safer before you expose the API to real users or tools.
Step 7. Use the JSON API
This is the part that makes the self-host SearXNG Docker setup useful for developers and AI pipelines. Because you added JSON to the formats list in settings.yml, you can now query the search API directly.
Keeping the self-host SearXNG Docker stack updated helps you pick up fixes and container changes from current releases.
Conclusion
This guide gives you a practical self-host SearXNG Docker setup that starts simple and becomes safer step by step. You first verify the app locally, then add Nginx, then enable HTTPS, and only after that turn on limiter protection for a public API.
That order is easier to debug, and it fits better for small VPS deployments that need a private search page or a controlled agent-search endpoint.
If you want to run this next to AI workloads, AI hosting plans are another useful option to consider.
We use cookies to run PerLod and to understand how the site is used. You can accept everything, or open Manage to turn individual categories off. Cookie policy.