Skip to main content

Web Crawler Add-On

Objective: start the web crawler containers so the Crawler integration can index websites.

Done when: pages from a website you added show up in search results.

What It Is​

The Crawler integration starts at a page you give it, follows that site's links to the depth you choose, and indexes each page. The add-on is two containers:

  • A headless browser (browserless Chromium) that loads each page the way your browser does, JavaScript included. Many sites build their content with JavaScript, and a plain download would find an empty page. The Crawler integration always renders through this browser, which is why it can't run without the add-on.
  • A Tor proxy that the browser fetches pages through. Sites that limit how many pages one address can load see different addresses instead of your home IP. When a site answers "too many requests" (429) or "busy" (503), the crawler asks the proxy for a new address and tries the page again later.

What It Costs​

  • Memory: the browser idles at about 210 MB and is capped at 2 GB while it renders. The proxy uses about 40 MB.
  • CPU: rendering a page takes real CPU. The browser renders one page at a time and is capped at 2 CPU cores, so a big crawl takes a while instead of taking over the machine.
  • Speed: pages load more slowly through Tor than directly. Some sites block Tor addresses entirely.

Before You Start​

You need a working Docker install.

1. Download the Crawler File​

From your Yew folder, next to docker-compose.yaml:

curl -fsSLO https://gitlab.com/alanjames1987/yew-monorepo/-/raw/main/infra/homelab/crawler.yaml

2. Add the Two Tokens​

The browser and the proxy each need a token, so nothing else on your network can use them. Generate two:

openssl rand -hex 24
openssl rand -hex 24

Create a file named .env in your Yew folder, next to docker-compose.yaml, if you don't have one yet. Add the two values to it:

.env
CRAWLER_TOKEN=<first value>
CRAWLER_PROXY_TOKEN=<second value>

Docker Compose reads .env from the same folder on every command. Without the two tokens, up -d stops with "Set CRAWLER_TOKEN in .env".

3. Start the Crawler​

Add a second -f:

docker compose -f docker-compose.yaml -f crawler.yaml up -d

This starts the browser and the proxy, and restarts the backend with HEADLESS_CRAWLER_URL set, which is what tells the backend the crawler is installed. The proxy takes 60 to 90 seconds to connect to Tor, and the browser waits for it.

Keep both files on every command

From now on, pass both -f flags to every command, including pull, logs and down. If you also use the agent, include all three: -f docker-compose.yaml -f agent.yaml -f crawler.yaml.

Check both started:

docker compose -f docker-compose.yaml -f crawler.yaml ps headless-crawler crawler-proxy

Both should be Up, and the proxy healthy.

4. Add a Website​

  1. In Yew, open Browse Integrations and click Add Integration next to Crawler.
  2. Optionally, enter a Name for it.
  3. Enter the Seed URL: the page to start from, such as a site's home page. The crawler only follows links on the same host name as this page.
  4. Choose a Max Crawl Depth: how many links away from the seed page to go. Leave it blank for 2. Start small (2 or 3), because the number of pages grows quickly with depth. A value of 0 is treated as 2.
  5. Set Refresh Mode. For a site that changes, use stale_only and set Refresh Interval (Minutes) (default 1440, one day). The default, new_only, never fetches a known page again, so it doesn't find pages added to the site after the first crawl. See Refresh Mode.
  6. Click Add Integration.

The first pages show up in search within a few minutes. The integration's page in My Integrations shows how many it has indexed so far.

Settings​

These go in the .env file next to docker-compose.yaml:

SettingDefaultWhat it does
CRAWLER_TOKEN(required)Token the backend uses to reach the browser
CRAWLER_PROXY_TOKEN(required)Token the backend uses to ask the proxy for a new address
CRAWLER_PROXY_ROTATE_MINUTES10Minutes between scheduled address changes. 0 turns the timer off. The crawler still asks for a new address when a site answers 429 or 503.

Troubleshooting​

The Crawler integration says "The web crawler add-on isn't installed". The backend doesn't have HEADLESS_CRAWLER_URL set, which usually means Yew was started without crawler.yaml. Run up -d again with both files:

docker compose -f docker-compose.yaml -f crawler.yaml up -d

It says "The web crawler isn't responding". The backend is set up to crawl, but the browser isn't answering. Check that it's running, then read its log and the proxy's:

docker compose -f docker-compose.yaml -f crawler.yaml ps headless-crawler crawler-proxy
docker compose -f docker-compose.yaml -f crawler.yaml logs headless-crawler crawler-proxy --tail 50

The browser won't start until the proxy is healthy, so a proxy stuck connecting to Tor keeps both down. The page checks again at most every 30 seconds, so reload it once they're up.

Pages fail with 429 or 503. The site is limiting requests. The crawler asks the proxy for a new address and retries on its own. The proxy log shows Identity rotated (on-demand) each time. If a site keeps refusing, it may block Tor entirely.

Still stuck? Ask at answers.yewsearch.com. It searches these docs with Yew Search and writes an answer with links to the pages it used.

Removing the Crawler​

Start Yew without crawler.yaml, and remove its containers:

docker compose -f docker-compose.yaml up -d --remove-orphans

Crawled pages stay searchable. Existing Crawler integrations stop updating until you add the crawler back.