Skip to content

RumenDamyanov/apache-gone

License

Apache Gone

An Apache httpd module that returns HTTP 410 Gone for URIs listed in a map file. Port of nginx-gone for Apache.

Features

  • Simple map file — one URI per line, read once at config load
  • Exact matching — O(1) hash table lookup for exact URIs
  • Regex matching — PCRE patterns with ~ (case-sensitive) and ~* (case-insensitive)
  • Per-context control — enable/disable at server or directory/location level
  • Early interception — translate_name hook, before content handlers
  • No dependencies — pure Apache API (APR), no external libraries
  • Dynamic module — works with LoadModule
  • nginx map compatible — reuse existing map files (second column ignored)

Documentation & Support

📖 Wiki - Guides, tutorials, and reference

💬 Discussions - Questions, help, and feedback

Quick Start

1. Install

Debian/Ubuntu:

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

Fedora/RHEL:

# Add the OBS repository (see Installation Guide for details)
dnf install apache-gone

2. Create a map file

cat > /etc/apache2/maps/gone.map <<EOF
# Removed blog posts
/blog/2020/deleted-post 1
/blog/2019/old-article 1

# Discontinued products
/products/old-widget 1

# Regex: everything under /deprecated/
~^/deprecated/ 1

# Case-insensitive: old PHP pages
~*^/old-(.*)\.php$ 1
EOF

3. Configure Apache

LoadModule gone_module modules/mod_gone.so

# Load the gone URI map (read once at startup / reload)
GoneMapFile /etc/apache2/maps/gone.map

<VirtualHost *:80>
    ServerName example.com
    GoneEnabled on

    DocumentRoot /var/www/html

    # Disable gone checking for the API
    <Location /api>
        GoneEnabled off
    </Location>
</VirtualHost>

4. Test

apachectl configtest && apachectl graceful
curl -I http://example.com/blog/2020/deleted-post
# HTTP/1.1 410 Gone

Configuration Reference

Directive Context Default Description
GoneEnabled server, directory, location off Enable/disable gone checking
GoneMapFile server config Path to URI list file
GoneUseRequestUri server config off Match original request URI instead of decoded URI

Map File Format

# Comments start with #
/exact/path 1              # Exact match
~^/regex/pattern 1         # Case-sensitive regex
~*^/case-insensitive 1     # Case-insensitive regex
  • One URI per line
  • Second column is optional (ignored, for nginx map compatibility)
  • ~ prefix = case-sensitive PCRE regex
  • ~* prefix = case-insensitive PCRE regex
  • Everything else = exact string match

Building from Source

cd src
apxs -i -a -c mod_gone.c

Repository Structure

  • src/ — Apache module source code
  • conf/ — Example configuration
  • test/ — Test suite
  • debian/ — Debian packaging files

Related Projects

Module Description GitHub
apache-cf-realip Automatic Cloudflare IP list for RemoteIPTrustedProxy GitHub
apache-torblocker Control access from Tor exit nodes GitHub
apache-waf IP/CIDR-based access control with named lists GitHub
apache-waf-api REST API daemon for dynamic IP list management GitHub
apache-waf-feeds Automatic threat feed updater GitHub
apache-waf-ui Web management interface GitHub

nginx Counterparts

nginx Module Apache Module
nginx-gone apache-gone (this project)
nginx-cf-realip apache-cf-realip
nginx-torblocker apache-torblocker
nginx-waf apache-waf

License

Apache License 2.0. See LICENSE.md.

About

Apache module for HTTP 410 Gone responses using URI map files with exact and regex matching

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Contributors