Apache TorBlocker

April 4, 2026 · View on GitHub

License

Apache TorBlocker

An Apache httpd module that controls access from Tor exit nodes. Supports three modes: block Tor traffic, allow only Tor traffic, or allow all. Port of nginx-torblocker for Apache.

Implementation: Rust core with thin C FFI shim for Apache module registration.

Features

  • Three access modesoff (allow all), on (block Tor), only (allow only Tor)
  • Automatic list fetching — downloads Tor exit node list without cron jobs
  • HTTPS support — secure list fetching with TLS verification
  • Per-location configuration — different policies for different paths
  • O(1) IP lookup — hash set for efficient IP matching
  • Automatic refresh — configurable update interval (default: 1 hour)
  • Fail-open by default — permissive during list fetch failures
  • Memory safe — Rust core prevents buffer overflows and use-after-free

Quick Start

1. Install

Debian/Ubuntu:

# Add the OBS repository (see Installation Guide for details)
apt install apache-torblocker

2. Configure Apache

LoadModule torblocker_module modules/mod_torblocker.so

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /var/www/html

    # Block Tor exit nodes
    TorBlock on

    # Allow Tor for anonymous tips
    <Location /anonymous-tips>
        TorBlock only
    </Location>
</VirtualHost>

3. Verify

apachectl configtest && apachectl graceful

Configuration Reference

DirectiveContextDefaultDescription
TorBlockserver config, virtual host, directory, locationoffoff / on (block Tor) / only (allow only Tor)
TorBlockSourceUrlserver configtorproject.orgTor exit list URL
TorBlockRefreshIntervalserver config3600Refresh interval in seconds

Building from Source

cargo build --release
make
sudo make install
ModuleDescriptionGitHub
apache-goneReturn HTTP 410 Gone for permanently removed URIsGitHub
apache-cf-realipAutomatic Cloudflare IP list for RemoteIPTrustedProxyGitHub
apache-wafIP/CIDR-based access control with named listsGitHub

nginx Counterpart

nginx ModuleApache Module
nginx-torblockerapache-torblocker (this project)

License

Apache License 2.0. See LICENSE.md.