Welcome! I’m thrilled to guide you through setting up your own private, self-hosted search engine using SearXNG and Tailscale. If you’re passionate about privacy and want to control your search experience, this comprehensive guide is for you.

Why Self-Host Your Search Engine?

In today’s digital age, online privacy is more crucial than ever. By self-hosting your search engine, you eliminate tracking and ads, ensuring a fully privacy-respecting experience. With tools like SearXNG and Tailscale, you can combine multiple search engines into one place while keeping everything under your control.

Getting Started with SearXNG and Tailscale

Before we dive into the setup, let’s briefly introduce the key players in our setup:

  • SearXNG: A fully open-source, self-hosted search engine that aggregates results from multiple search engines without tracking your activities.
  • Tailscale: A mesh VPN network that simplifies secure networking, allowing you to connect devices securely and privately.

Setting Up Your Proxmox Environment

To host our applications effectively, we’ll use Proxmox, a powerful virtualization platform. I’ll walk you through setting up a Proxmox cluster and creating a runtime environment for SearXNG.

Downloading a Debian Template

We’ll start by downloading a Debian template for our container:

  • Navigate to the local storage option on your Proxmox node.
  • Click on CT Templates.
  • Select Templates and search for Debian.
  • Choose the latest version available (e.g., 12.7-1).
💡
Using the latest Debian template ensures you have the most up-to-date features and security patches.

Creating a Container

Next, we’ll create a new container where SearXNG will run:

  • Click on Create CT in the top right corner.
  • Assign a unique ID (e.g., 2001) and name your container (I named mine “Space Oddity“).
  • Set a strong password for the container.
  • Skip the SSH key setup—we’ll handle networking with Tailscale.

Configuring Resources

Allocate resources to ensure smooth performance:

  • Storage: Allocate around 20 GB on the local node.
  • CPUs: Assign 4 CPU cores for optimal performance.
  • RAM: Allocate 4 GB of RAM.
💪
These resources are recommendations; adjust them based on your hardware capabilities.

Networking Setup

  • Assign an IP address to the container (e.g., 10.42.37.100/24).
  • The /24 denotes a subnet mask of 255.255.255.0.
  • Enter your network’s gateway IP (e.g., <your-gateway-ip>).

This completes the basic setup of your Proxmox container. Now, let’s install Tailscale and Docker within it.

Installing Tailscale and Docker

With the container ready, we’ll install Tailscale and Docker to facilitate networking and application deployment.

Modifying the LXC Container Configuration

To allow Tailscale to function correctly, we need to adjust the container’s configuration:

  • Locate your container ID (e.g., 2001).
  • Edit the container’s configuration file:
    nano /etc/pve/lxc/2001.conf

  • Add the following line to grant the necessary permissions:
    lxc.cgroup.devices.allow: c 10:200 rwm

  • Save and exit the editor.
  • Start the container:
    pct start 2001

Ensure you add the permission line correctly to avoid issues with Tailscale.

Updating the Container Packages

I recommend updating all packages inside the container:

apt update && apt upgrade -y

This ensures your system is up-to-date with the latest security patches.

Installing Tailscale

Install Tailscale using the official script:

curl -fsSL https://tailscale.com/install.sh | sh

If curl isn’t installed, get it first:

apt install curl -y

Installing Docker

Next, install Docker to run our applications:

curl -fsSL https://get.docker.com | sh

This script installs Docker quickly and efficiently.

Creating the Docker Compose File for SearXNG

With Docker installed, we’ll create a Docker Compose file to define our SearXNG service.

Logging In and Setting Up Tailscale

After a system reboot, log back in and initialize Tailscale:

tailscale up --ssh

Follow the authentication URL provided to connect your device to your Tailscale network.

Preparing the Docker Compose File

Create and edit the Docker Compose file:

nano docker-compose.yaml

Insert the following content:

version: '3'
services:
  searxng:
    image: searxng/searxng
    restart: always
    ports:
      - "8080:8080"
    environment:
      - BASE_URL=https://<your-tailscale-domain>
    depends_on:
      - redis
  redis:
    image: redis:alpine
💪
Replace <your-tailscale-domain> with your actual Tailscale domain, which you can find in your Tailscale admin console under DNS settings.

Setting the Base URL

Ensure the BASE_URL environment variable matches your Tailscale domain for proper HTTPS functionality.

Running Your Private Search Engine

Now, we’ll start the Docker containers and get our search engine running.

Starting the Docker Services

Run the following command to start SearXNG and Redis:

docker-compose up -d

The -d flag runs the containers in the background.

Accessing SearXNG Locally

Open your web browser and navigate to:

http://localhost:8080

You should see the SearXNG interface ready for your queries.

Testing the Search Functionality

Try searching for something like “open-source projects.” You’ll receive results aggregated from multiple search engines, including DuckDuckGo, Google, and Wikipedia—all without ads or tracking.

✔️
Your private search engine is up and running!

Integrating SearXNG with Tailscale for Secure Access

To securely access your search engine from anywhere, we’ll integrate it with Tailscale.

Enabling Magic DNS and HTTPS Certificates

  • In the Tailscale admin console, go to DNS settings.
  • Enable Magic DNS to simplify domain resolution.
  • Enable HTTPS Certificates to obtain TLS certificates for your devices.
💡
Magic DNS allows you to access your devices using domain names instead of IP addresses.

Accessing SearXNG via Tailscale Domain

Now, you can access your search engine securely:

https://search.<your-tailnet-name>.ts.net

This URL uses the TLS certificate provided by Tailscale, ensuring secure communication.

Infographic showing the integration of Proxmox, Docker, SearXNG, and Tailscale
Infographic showing the integration stack
✔️
Your search engine is now accessible securely from anywhere within your Tailscale network!

Setting SearXNG as Your Default Search Engine in Chrome

Enhance your browsing experience by setting SearXNG as your default search engine in Google Chrome.

Steps to Configure Chrome

  • Open Chrome and go to Settings.
  • Click on Search Engine in the sidebar.
  • Select Manage Search Engines and Site Search.
  • Under Site Search, click on Add.
  • Fill in the details:
    • Search engine: SearXNG
    • Shortcut: sx
    • URL: https://search.<your-tailnet-name>.ts.net/search?q=%s
  • Click Add.
  • Find SearXNG in the list and click on the three dots next to it.
  • Select Make default.

Now, any searches you perform from the address bar will use your private SearXNG instance.

Recap and Final Thoughts

We’ve accomplished a lot! Here’s what we did:

  • Set up a Proxmox environment and created an LXC container.
  • Installed Tailscale and Docker within the container.
  • Configured and ran a private instance of SearXNG.
  • Integrated Tailscale for secure, private access from anywhere.
  • Set SearXNG as the default search engine in Chrome.

By following this guide, you’ve taken control of your search experience, prioritizing privacy and security. I encourage you to explore more features of Tailscale and SearXNG to further customize your setup.

💡
For more details on Tailscale and its capabilities, visit their official documentation.

Additional Tips and Resources

Exploring SearXNG Settings

SearXNG offers extensive customization:

  • Adjust search categories (e.g., images, news, science).
  • Configure search engine preferences and weights.
  • Enable or disable specific search engines.

Securing Your Setup Further

Consider implementing additional security measures:

  • Use firewall rules to restrict access.
  • Regularly update your Docker images.
  • Monitor logs for any unusual activity.

Scaling and Performance

If you plan to support multiple users:

  • Consider increasing CPU and RAM allocations.
  • Use Docker Swarm or Kubernetes for scalability.
  • Implement caching mechanisms for faster responses.

Conclusion

Thank you for joining me on this journey to set up a private, self-hosted search engine. By taking these steps, you’ve enhanced your online privacy and gained greater control over your search experience.

If you have any questions or need further assistance, feel free to reach out. Happy searching!


Categorized in:

Proxmox, Servers, Tech, Tutorials,