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:
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> searxng<br /><span style="color: #7a0874; font-weight: bold;">cd</span> searxng
Clone the searxng-docker git repository:
<span style="color: #c20cb9; font-weight: bold;">git clone</span> https:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>searxng<span style="color: #000000; font-weight: bold;">/</span>searxng-docker.git<br /><span style="color: #7a0874; font-weight: bold;">cd</span> searxng-docker
Open the docker-compose.yml file
<span style="color: #c20cb9; font-weight: bold;">nano</span> docker-compose.yml
You should see something similar to this:
<span style="color: #007F45;">services</span>:<span style="color: #007F45;"><br /> caddy</span>:<span style="color: green;"><br /> container_name</span><span style="font-weight: bold; color: brown;">: </span>caddy<span style="color: green;"><br /> image</span><span style="font-weight: bold; color: brown;">: </span>docker.io/library/caddy:2-alpine<span style="color: green;"><br /> network_mode</span><span style="font-weight: bold; color: brown;">: </span>host<span style="color: green;"><br /> restart</span><span style="font-weight: bold; color: brown;">: </span>unless-stopped<span style="color: #007F45;"><br /> volumes</span><span style="font-weight: bold; color: brown;">:<br /></span> - ./Caddyfile:/etc/caddy/Caddyfile:ro<br /> - caddy-data:/data:rw<br /> - caddy-config:/config:rw<span style="color: #007F45;"><br /> environment</span><span style="font-weight: bold; color: brown;">:<br /></span> - SEARXNG_HOSTNAME=$<span class="br0">{</span>SEARXNG_HOSTNAME:-http://localhost<span class="br0">}</span><br /> - SEARXNG_TLS=$<span class="br0">{</span>LETSENCRYPT_EMAIL:-internal<span class="br0">}</span><span style="color: #007F45;"><br /> cap_drop</span><span style="font-weight: bold; color: brown;">:<br /></span> - <span style="font-weight: bold;">ALL</span><span style="color: #007F45;"><br /> cap_add</span><span style="font-weight: bold; color: brown;">:<br /></span> - NET_BIND_SERVICE<span style="color: #007F45;"><br /> logging</span>:<span style="color: green;"><br /> driver</span><span style="font-weight: bold; color: brown;">: </span><span style="color: #CF00CF;">"json-file"</span><span style="color: #007F45;"><br /> options</span>:<span style="color: green;"><br /> max-size</span><span style="font-weight: bold; color: brown;">: </span><span style="color: #CF00CF;">"1m"</span><span style="color: green;"><br /> max-file</span><span style="font-weight: bold; color: brown;">: </span><span style="color: #CF00CF;">"1"</span><br /><span style="color: #007F45;"><br /> redis</span>:<span style="color: green;"><br /> container_name</span><span style="font-weight: bold; color: brown;">: </span>redis<span style="color: green;"><br /> image</span><span style="font-weight: bold; color: brown;">: </span>docker.io/valkey/valkey:8-alpine<span style="color: green;"><br /> command</span><span style="font-weight: bold; color: brown;">: </span>valkey-server --save 30 1 --loglevel warning<span style="color: green;"><br /> restart</span><span style="font-weight: bold; color: brown;">: </span>unless-stopped<span style="color: #007F45;"><br /> networks</span><span style="font-weight: bold; color: brown;">:<br /></span> - searxng<span style="color: #007F45;"><br /> volumes</span><span style="font-weight: bold; color: brown;">:<br /></span> - valkey-data2:/data<span style="color: #007F45;"><br /> cap_drop</span><span style="font-weight: bold; color: brown;">:<br /></span> - <span style="font-weight: bold;">ALL</span><span style="color: #007F45;"><br /> cap_add</span><span style="font-weight: bold; color: brown;">:<br /></span> - SETGID<br /> - SETUID<br /> - DAC_OVERRIDE<span style="color: #007F45;"><br /> logging</span>:<span style="color: green;"><br /> driver</span><span style="font-weight: bold; color: brown;">: </span><span style="color: #CF00CF;">"json-file"</span><span style="color: #007F45;"><br /> options</span>:<span style="color: green;"><br /> max-size</span><span style="font-weight: bold; color: brown;">: </span><span style="color: #CF00CF;">"1m"</span><span style="color: green;"><br /> max-file</span><span style="font-weight: bold; color: brown;">: </span><span style="color: #CF00CF;">"1"</span><br /><span style="color: #007F45;"><br /> searxng</span>:<span style="color: green;"><br /> container_name</span><span style="font-weight: bold; color: brown;">: </span>searxng<span style="color: green;"><br /> image</span><span style="font-weight: bold; color: brown;">: </span>docker.io/searxng/searxng:latest<span style="color: green;"><br /> restart</span><span style="font-weight: bold; color: brown;">: </span>unless-stopped<span style="color: #007F45;"><br /> networks</span><span style="font-weight: bold; color: brown;">:<br /></span> - searxng<span style="color: #007F45;"><br /> ports</span><span style="font-weight: bold; color: brown;">:<br /></span> - <span style="color: #CF00CF;">"8080:8080"</span><span style="color: #007F45;"><br /> volumes</span><span style="font-weight: bold; color: brown;">:<br /></span> - ./searxng:/etc/searxng:rw<span style="color: #007F45;"><br /> environment</span><span style="font-weight: bold; color: brown;">:<br /></span> - SEARXNG_BASE_URL=https://$<span class="br0">{</span>SEARXNG_HOSTNAME:-localhost<span class="br0">}</span>/<br /> - UWSGI_WORKERS=$<span class="br0">{</span>SEARXNG_UWSGI_WORKERS:-4<span class="br0">}</span><br /> - UWSGI_THREADS=$<span class="br0">{</span>SEARXNG_UWSGI_THREADS:-4<span class="br0">}</span><span style="color: #007F45;"><br /> cap_drop</span><span style="font-weight: bold; color: brown;">:<br /></span> - <span style="font-weight: bold;">ALL</span><span style="color: #007F45;"><br /> cap_add</span><span style="font-weight: bold; color: brown;">:<br /></span> - CHOWN<br /> - SETGID<br /> - SETUID<span style="color: #007F45;"><br /> logging</span>:<span style="color: green;"><br /> driver</span><span style="font-weight: bold; color: brown;">: </span><span style="color: #CF00CF;">"json-file"</span><span style="color: #007F45;"><br /> options</span>:<span style="color: green;"><br /> max-size</span><span style="font-weight: bold; color: brown;">: </span><span style="color: #CF00CF;">"1m"</span><span style="color: green;"><br /> max-file</span><span style="font-weight: bold; color: brown;">: </span><span style="color: #CF00CF;">"1"</span><br /><span style="color: #007F45;"><br />networks</span>:<span style="color: #007F45;"><br /> searxng</span><span style="font-weight: bold; color: brown;">:<br /></span><span style="color: #007F45;"><br />volumes</span>:<span style="color: #007F45;"><br /> caddy-data</span>:<span style="color: #007F45;"><br /> caddy-config</span><span style="font-weight: bold; color: brown;">:<br /></span> 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: - ALLline from the docker-compose file. Once you have set it up, restore thecap_drop: - ALLline 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:
<span style="color: #c20cb9; font-weight: bold;">nano</span> .env
You should see something like this:
<span style="color: #666666; font-style: italic;"># By default listen on https://localhost</span><br /><span style="color: #666666; font-style: italic;"># To change this:</span><br /><span style="color: #666666; font-style: italic;"># * uncomment SEARXNG_HOSTNAME, and replace <host> by the SearXNG hostname</span><br /><span style="color: #666666; font-style: italic;"># * uncomment LETSENCRYPT_EMAIL, and replace <email> by your email (require to create a Let's Encrypt certificate)</span><br /><br /><span style="color: #666666; font-style: italic;"># SEARXNG_HOSTNAME=<host></span><br /><span style="color: #666666; font-style: italic;"># LETSENCRYPT_EMAIL=<email></span><br /><br /><span style="color: #666666; font-style: italic;"># Optional:</span><br /><span style="color: #666666; font-style: italic;"># 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</span><br /><span style="color: #666666; font-style: italic;"># More workers (= processes) means that more search requests can be handled at the same time, but it also causes more resource usage</span><br /><br /><span style="color: #666666; font-style: italic;"># SEARXNG_UWSGI_WORKERS=4</span><br /><span style="color: #666666; font-style: italic;"># SEARXNG_UWSGI_THREADS=4</span>
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:
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #ff0000;">"s|ultrasecretkey|<span style="color: #007800;">$(openssl rand -hex 32)</span>|g"</span> searxng<span style="color: #000000; font-weight: bold;">/</span>settings.yml
Lastly, start your SearXNG instance:
<span style="color: #c20cb9; font-weight: bold;">docker compose</span> up <span style="color: #660033;">-d</span>
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.

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

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”.

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.

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.

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

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.