Hacking SearX Docker, Nginx and Cloudflare together the wrong way

SearX is a great meta search engine that aggrgate multiple engine’s result together, giving you privacy during searching.

A list of public instances can be found at https://searx.space/ – however it’s not possible to know what logging those public instances are putting up. Some public instances are using Cloudflare, which is OK – but some tends to set the senstivity too high which ruins the experience. Note Cloudflare can see everything – but for personal users you do need that to stop bots.

A better solution is to create your own instance, and share with your friends. The sharing step is as important as setting up – otherwise it’s effectly the same as you are using a single proxy. But think twice before setting up public instance unless you know what you are doing.

SearX has an official Docker Compose repo at https://github.com/searx/searx-docker – but I am already running Nginx on 443. So I need to hack the setup to make my current setup working with the new containers. Make sure you read https://github.com/searx/searx-docker#what-is-included- and understand which part is for what.

Grab this repo, edit .env file as instructed, and run ./start.sh once. Don’t worry about issues: we will hack them though.

Hacking Caddyfile

I should not use Caddy with Nginx but to make it working:

  1. Remove all morty related content
  2. If you want to use Cloudflare, hack Content-Security-Policy and add https://ajax.cloudflare.com/ in script-src 'self'; otherwise rocket loader won’t work.

Hacking searx/settings.yml

You need to change the Morty related stuffs at the end. Hardcode your Morty URL in, like https://search.fancy.tld/morty .

Hacking docker-compose.yml

  1. For Caddy, bind 80 to other ports. Like 4180:80.
  2. For morty: limit port 3000 to only localhost.
  3. For searx: hardcode morty related URL in.

Hacking .env

  1. Put localhost:4180 in host so Caddy won’t take port 80 from Nginx.
  2. Use HTTP only. We shall do SSL with Nginx.

Hacking rules.json

Remove the block deflate part if you need Cloudflare.

Hacking Nginx

Try this setup:

Note you must use upstream for reverse proxy or morty will complain.

With all the setup you should have something more or less usable. Wait for the checker to finish for optimized list of engines to enable – and note Qwant and DDG both uses Bing result, while Startpage is watered down Google.

If you want to set your SearX as default search engine for Chrome: visit your site, go to and your engine should be selectable. You may need to change the URL.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.