linux, how to

SearXNG is a powerful meta-search engine that you can host anywhere. Unlike traditional search engines, SearXNG is an engine aggregator. This means that instead of processing searches by itself, it uses other engines to do the searching for it. Further, SearXNG is incredibly lightweight and easy to set up, and you can host it on a system as simple as a Raspberry Pi!

Content

  • Why Install SearXNG
  • What You’ll Need
  • Installing SearXNG’s Dependencies
  • Configuring Your Firewall
  • Cloning and Installing SearXNG
  • Configuring SearXNG
  • Installing SSL and Enabling SearXNG
  • Frequently Asked Questions

Why Install SearXNG

Search engines make it incredibly convenient to browse and discover the web. However, using a public search engine comes with a price – modern search companies such as Google use your search data to create a highly accurate profile of you.

linux, how to

This behavior can feel intrusive to individuals who want to keep their searches private and anonymous. For example, journalists who are reporting about sensitive and controversial topics might not want to associate their search queries with their names.

linux, how to

One way to deal with this privacy issue is by installing and hosting your own instance of SearXNG. This ensures that only you will have access to your search logs.

What You’ll Need

SearXNG requires you to have a few things ready before you can install it:

  • A Fully Qualified Domain Name (FQDN): to use SearXNG, you need to host it through a proper web server with a domain.
  • A machine accessible from outside your home network: this can either be a computer at your house that has a Static IP address or a dedicated Virtual Private Server (VPS) that you are currently renting.
  • Root access to your machine: this is because SearXNG requires you to install some system tools to configure and host it properly.

This tutorial focuses only on installing and setting up SearXNG on a Debian 11 VPS from DigitalOcean.

linux, how to

Installing SearXNG’s Dependencies

Before you can install SearXNG, you need to create a separate user account in your system:

sudo useradd -s /bin/bash -d /home/searx -m -G sudo searx sudo passwd searx

linux, how to

Doing this allows you to isolate all the commands and files when installing and configuring SearXNG. This can be especially useful if you intend to host the search engine on a VPS with multiple services.

Once done, you need to switch to the new user account by running su searx. From there, you can now install all the necessary dependencies for SearXNG:

sudo apt install git nginx iptables iptables-persistent ufw certbot python3-certbox-nginx

linux, how to

Configuring Your Firewall

While this is not a necessary step, configuring your firewall makes sure that any outside system will only be able to access ports authorized by you. This can help prevent any malicious actors from flooding your machine with endless requests.

linux, how to

You can use both iptables and ufw to enable only the ports that SearXNG needs:

sudo iptables -I INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT sudo iptables -I INPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT sudo netfilter-persistent save sudo ufw allow 80 sudo ufw allow 443
  • The two iptables commands create a new rule that accepts any incoming new HTTP and HTTPS connections to your machine. This, in turn, allows your system to serve the SearXNG webpage to your users.
  • The netfilter-persistent command saves and reloads any changes that you make to your firewall. This ensures that your machine has the right settings in between system restarts.
  • Lastly, the two ufw commands make sure that any current connection in both HTTP and HTTPS remains open for the duration of the session.

Cloning and Installing SearXNG

The next thing you need to do is download and install SearXNG on your machine. The program’s developers offer a simple installation script that handles most of the complicated configuration steps.

linux, how to

You can obtain this installation script by cloning the program’s GitHub repository:

git clone https://github.com/searxng/searxng searxng && cd searxng

linux, how to

Once the cloning is complete, you can start the installation process:

sudo -H ./utils/searxng.sh install all

While this process is largely automatic, there are instances where the script asks you to confirm the changes that it is making. For example, when the SearXNG script prints a list of programs that it will install, you need to press Y to continue.

linux, how to

Configuring SearXNG

Once SearXNG is on your machine, you need to configure a web server that will broadcast it, because the search engine is just a process that takes requests and posts results. This means that without a proper web server, it is not possible to interact with and use SearXNG.

linux, how to

At the moment, SearXNG officially supports both Apache and Nginx. This section focuses on configuring SearXNG as a standalone service using Nginx.

Configuring Nginx

First, you need to create a new configuration file under “/etc/nginx/sites-available/”:

sudo nano /etc/nginx/sites-available/searxng

You need to then write a server block inside the file that will contain the web server’s configuration. For example, this is a basic block that I am using for my SearXNG instance:

server {       # Ports.     listen 80;     listen [::]:80;       # Hostname.     server_name yetanothersearxserver.xyz;       # Logging.     access_log /dev/null;     error_log  /dev/null;       # Searx Redirect.     location / {         uwsgi_pass unix:///usr/local/searxng/run/socket;           include uwsgi_params;           uwsgi_param    HTTP_HOST             $host;         uwsgi_param    HTTP_CONNECTION       $http_connection;           # see flaskfix.py         uwsgi_param    HTTP_X_SCHEME         $scheme;         uwsgi_param    HTTP_X_SCRIPT_NAME    /searxng;           # see limiter.py         uwsgi_param    HTTP_X_REAL_IP        $remote_addr;         uwsgi_param    HTTP_X_FORWARDED_FOR  $proxy_add_x_forwarded_for;       } }
  • The listen variables tell Nginx that this web server broadcasts a service at port 80. It is important to change this value if you are already running a different virtual host in your system.
  • The server_name is a variable that should contain an FQDN that points to your machine. In my case, my webserver uses “yetanothersearxserver.xyz.”
  • Both the access_log and error_log variables tell Nginx where to save any information about your search queries. For example, setting it to “/dev/null” ensures that you are not saving any logs in the machine.
  • Lastly, the location block tells Nginx what to do whenever a user connects to the web server.

linux, how to

Installing SSL and Enabling SearXNG

The next thing you need to do is create an SSL certificate for your SearXNG instance. Doing this makes sure that every connection you make to your website is secure.

linux, how to

You can easily enable SSL for free by signing up with Lets Encrypt‘s certbot. For example, I can run the following command to issue a certificate for my SearXNG host:

certbot --nginx yetanothersearxserver.xyz

You can now enable your website through Nginx by creating a symbolic link to the web server’s “sites_enabled” folder:

sudo ln -s /etc/nginx/sites-available/searx /etc/nginx/sites-enabled/

Once done, you need to reload both SearXNG and Nginx to apply and enable your configurations:

sudo systemctl reload nginx sudo service uwsgi restart searxng

Congratulations! You now know how to create and host your own search engine using SearXNG.

Frequently Asked Questions

Is it possible to update SearXNG once I install it?

Yes! While you cannot install SearXNG through a traditional package manager, it is possible to update and migrate the search engine from the command line. For example, you can update SearXNG by running the following command: sudo /home/$USER/searxng/utils/searxng.sh instance update.

The installation script is telling me that Redis is not available. Did my installation fail?

No. But this error will most likely cause your SearXNG instance to be unstable. This is because a Redis failure in SearXNG means that it is running in a non-SystemD system and its anti-bot filtering daemon is not running.

To fix this, you need to uninstall SearXNG by running the following command: sudo /home/$USER/searxng/utils/searxng.sh remove all. Lastly, you also need to make sure that you are using SystemD by running the following: sudo systemctl --version.

Is it possible to see what SearXNG is currently doing?

Yes! While SearXNG is a headless daemon that runs in the background, it is possible to check on what it is currently doing. This is useful in instances where SearXNG is encountering some problems and you are not sure what is causing those issues. For example, I can tap into SearXNG’s debug screen by running the following command: sudo /home/$USER/searxng/utils/searxng.sh instance inspect.

Image credit: Isaac Quesada via Unsplash, altered by Ramces Red. SearXNG Logo and Wordmark. All screenshots by Ramces Red.

TECH NEWS RELATED

How to Block Websites on Android

Joe Fedewa / How-To Geek To block websites on Android, install a third-party app like BlockSite, or use Mozilla Firefox as your browser and get a website-blocking add-on. Switching to a custom DNS server will also block a wide swath of time-wasting and inappropriate websites at once for all ...

View more: How to Block Websites on Android

The best YouTube VPN 2022

Your favorite videos, no matter where you are

View more: The best YouTube VPN 2022

Dragon Quest Treasures

Another Dragon Quest spinoff is about to make the Nintendo Switch its home, and this time around it’s starring everyone’s favorite thief from Dragon Quest XI, Erik, along with his sister Mia. Set in a time before the events of Dragon Quest XI, Dragon Quest Treasures starts with a young ...

View more: Dragon Quest Treasures

How to Delete Photos from iCloud

If you’re running out of room on iCloud, you’ll need to reclaim some by removing photos. Learn how to delete photos on iCloud here. If you’re an Apple device user or you’ve signed up for an Apple ID, you get 5 GB of free storage on iCloud. The company ...

View more: How to Delete Photos from iCloud

Hello Neighbor 2: How to Solve the Dollhouse Puzzle in Act 1

Wondering how to open the dollhouse in Hello Neighbor 2 for one of the four basement keys in Act 1? Here's where to find all doll locations.

View more: Hello Neighbor 2: How to Solve the Dollhouse Puzzle in Act 1

Hello Neighbor 2: How to Get the Scissors in Act 1

Wondering where the scissors are in Hello Neighbor 2, Act 1? Here's how to get them and solve the robot arm puzzle.

View more: Hello Neighbor 2: How to Get the Scissors in Act 1

The best laptops under $1,000/£1,000

Our pick of the best laptops for under a grand

View more: The best laptops under $1,000/£1,000

Microsoft Returns to the JEDI Cloud Project, This Time with Oracle, Google, and Amazon

The JEDI war cloud contract is back – now known as JWCC – and the Pentagon is seeking a multi-cloud approach for the $9bn project.

View more: Microsoft Returns to the JEDI Cloud Project, This Time with Oracle, Google, and Amazon

Disney+ rolls out ad-supported tier to better compete with Netflix

Pokemon Scarlet And Violet Double Pack Gets Nice Discount

Get 10 Anime-Themed Steam Games For Just $4

Mike Flanagan And Trevor Macy See House Of Usher As Their Perfect Exit From Netflix

Boost Infinite’s New Mobile Service Offers Unlimited Everything for $25

Realme 10 Pro+ Review: Curved display steals the show

The best 55-inch 4K TVs 2022: OLED and QLED TVs for all budgets

What Is ChatGPT and How to Use It to Generate Text

Intel teases Sapphire Rapids workstation CPUs coming "pretty soon"

Marvel Snap Debuts Free Login Bonus, New Variant Bundle

Apex Legends Leak Suggests A Punishing New LTM For Hardcore Players Is On The Way

Today's Wordle Answer (#538) - December 9, 2022

OTHER TECH NEWS

Top Car News Car News