Get Running in Minutes
One command. Interactive feature selection. Onion address generated in under 90 seconds on a clean Debian 13 system.
$ git clone https://github.com/ashardian/OnionSite-Aegis.git $ cd OnionSite-Aegis $ chmod +x install.sh $ sudo ./install.sh
$ sudo cat /var/lib/tor/hidden_service/hostname
y. If you answer no, nftables will drop all inbound connections including your SSH session and you will be locked out./var/lib/tor/hidden_service/ means losing your onion address permanently โ there is no recovery. Run sudo ./SAVE_MY_ONION.sh now.System Requirements
Aegis v10.0 is a bare-metal-only tool. Docker support was permanently removed because it conflicts with kernel-level sysctl hardening, NFTables management, Tor Sandbox mode, and tmpfs RAM logging.
tor@defaulttor also supported.cat /etc/os-release # Check distro df -h / # Check disk space free -h # Check RAM whoami # Must be root or sudo capable
Full Installation Guide
The Architect Installer is fully interactive. Every feature can be toggled independently. Here is what happens at each step.
Download the repository
Clone from GitHub or unzip the release archive into any directory.
git clone https://github.com/ashardian/OnionSite-Aegis.git && cd OnionSite-Aegis
Run the installer as root
The installer will auto-detect your Tor service unit (tor or tor@default) and your system's nginx module paths before doing anything.
chmod +x install.sh && sudo ./install.sh
Answer the interactive prompts
Press Enter to accept the default (Yes) for each module, or type n to disable. All defaults are production-recommended.
Identity wipe decision
If a previous hidden service exists, the installer prompts you to type wipe for a new address or press Enter to preserve the existing one.
Wait for onion address generation
The installer waits up to 60 seconds for Tor to generate /var/lib/tor/hidden_service/hostname. Your address is printed on success.
What the installer does internally
- Sanitize โ Stops all services, removes all Nginx configs, moves old module symlinks to a backup dir, optionally wipes hidden service keys.
- Dependencies โ Installs tor, nginx, nftables, python3-stem, python3-inotify, libmodsecurity3, libnginx-mod-http-modsecurity, libnginx-mod-http-lua via apt.
- RAM Logging โ Mounts a 10MB tmpfs at
/var/log/torwith mode 0700, owned by debian-tor. No logs ever touch disk. - Tor hardening โ Writes a hardened
/etc/tor/torrcwith SafeLogging, AvoidDiskWrites, V3 hidden service, cookie auth on control port. - Nginx architecture โ Links modules in correct load order (NDK โ Lua โ WAF), builds site config with WAF and Lua directives, downloads unicode.mapping, rewrites SecUnicodeMapFile to absolute path, validates with
nginx -tbefore firewall applies. - Firewall โ Deploys balanced NFTables ruleset, optionally uncomments SSH rule, validates with
nft -cbefore applying. - Services โ Deploys neural-sentry.service, privacy-monitor.timer, traffic-protection.service as systemd units with correct dependencies.
- Bootstrap โ Restarts Tor and nginx, waits for onion address, prints result.
After the Install Completes
Verify services, add your content, and back up your keys.
sudo systemctl status tor@default # Real Tor process on Debian 13 sudo systemctl status nginx sudo systemctl status neural-sentry sudo systemctl status privacy-monitor.timer sudo systemctl status traffic-protection.service sudo mount | grep tmpfs | grep tor # Confirm RAM logging active sudo ls -la /var/lib/tor/hidden_service/ # Keys + hostname sudo nginx -t # Confirm WAF config OK
sudo aegis-edit # Built-in nano editor + auto-reload # Or copy a full site manually: sudo cp -r /path/to/your/site/* /var/www/onion_site/ sudo chown -R www-data:www-data /var/www/onion_site sudo systemctl reload nginx
sudo ./SAVE_MY_ONION.sh # Built-in backup tool # Manual alternative: sudo tar -czf onion-backup-$(date +%Y%m%d).tar.gz /var/lib/tor/hidden_service/
Neural Sentry IPS
An active-defense Python daemon that monitors your Tor control port in real time and kills circuits the moment an attack signature is detected.
How it works
- Connects to the Tor control port at
127.0.0.1:9051using cookie authentication viapython3-stem. - Monitors the rate of new circuit creation. A sudden spike is the primary signature of a DDoS or circuit-flooding attack.
- On detection, sends a
NEWNYMsignal โ forcing Tor to rotate all circuits and sever the attacker's connection path instantly. - Uses
python3-inotifyfor file integrity monitoring โ any unexpected change to the web root or config files triggers an alert. - All sentry events logged to
/var/log/tor/sentry.logโ inside the RAM disk, wiped on reboot.
| Parameter | Value |
|---|---|
| Systemd unit | neural-sentry.service |
| Control interface | 127.0.0.1:9051 |
| Auth method | Cookie (CookieAuthentication 1) |
| Log file | /var/log/tor/sentry.log (RAM) |
| Restart policy | always |
| Runs as | root |
sudo systemctl status neural-sentry sudo journalctl -u neural-sentry -f sudo tail -f /var/log/tor/sentry.log
ModSecurity Web Application Firewall
Full ModSecurity v3 integrated into nginx. Blocks SQLi, XSS, shell uploads, and other application-layer attacks before they reach Tor.
modsecurity.conf-recommended references unicode.mapping via a relative path. Aegis downloads it automatically and rewrites SecUnicodeMapFile to an absolute path โ fixing the nginx startup crash that affected older installs.Installation details
- Package:
libnginx-mod-http-modsecurity+libmodsecurity3 - Config downloaded from
SpiderLabs/ModSecurityGitHub (v3 master branch) unicode.mappingdownloaded to/etc/nginx/modsec/alongside the confSecRuleEngine DetectionOnlyrewritten toSecRuleEngine On(blocking mode)- Main rules file:
/etc/nginx/modsec/main.confโ includesmodsecurity.conf - Nginx site config includes
modsecurity onandmodsecurity_rules_filedirectives
nginx -t # Config test โ must pass ls /etc/nginx/modsec/ # Should show modsecurity.conf + unicode.mapping grep "SecRuleEngine" /etc/nginx/modsec/modsecurity.conf # Should say "On"
sudo wget https://raw.githubusercontent.com/SpiderLabs/ModSecurity/v3/master/unicode.mapping \
-O /etc/nginx/modsec/unicode.mapping
sudo sed -i "s|SecUnicodeMapFile unicode.mapping|SecUnicodeMapFile /etc/nginx/modsec/unicode.mapping|g" \
/etc/nginx/modsec/modsecurity.conf
sudo nginx -t && sudo systemctl reload nginx
Balanced NFTables Firewall
Previous versions used aggressive rate limiting that blocked Tor's own directory fetches, causing "Onion Site Not Found" on first launch. v10.0 uses stateful tracking โ Tor sees everything it needs, attackers see nothing.
Ruleset logic
- Loopback always accepted โ nginx and Tor communicate over localhost. This chain must never be blocked.
- ct state established,related accept โ Replies to Tor's outbound connections are always allowed. This is what broke in old versions.
- ct state invalid drop โ Malformed packets dropped before they consume resources.
- ICMP rate limited โ 5 packets/second. Ping works but ICMP flood does not.
- Default: DROP โ All unsolicited inbound connections dropped. Port scanners see nothing.
- Forward: DROP โ The server cannot be used as a router or relay.
- Output: ACCEPT โ Tor needs unrestricted outbound to reach the network.
table inet filter { chain input { type filter hook input priority 0; policy drop; iifname "lo" accept # loopback ct state established,related accept # Tor replies ct state invalid drop # malformed ip protocol icmp ... limit rate 5/second accept # tcp dport 22 accept โ SSH Safety Valve (disabled by default) log prefix "FIREWALL-DROP: " drop } chain forward { policy drop; } chain output { policy accept; } }
sudo nft list ruleset
sudo nft list table inet filter
sudo journalctl -k | grep "FIREWALL-DROP" # See what's being dropped
sudo nft flush ruleset, then re-run the installer with SSH enabled.Amnesic Logging Architecture
Every log is stored in volatile RAM. Power loss or reboot is a full forensic wipe. No persistent evidence of traffic ever exists on disk.
RAM disk setup
/var/log/tormounted astmpfsโ 10MB, mode 0700, owned bydebian-tor- Tor configured with
AvoidDiskWrites 1โ minimizes state written to persistent storage SafeLogging 1in torrc โ IPs replaced with safe placeholders at Tor levelprivacy_log_sanitizer.pyruns via Privacy Monitor โ scrubs any remaining IPs or hostnames from RAM logs
/etc/fstab. After a reboot, /var/log/tor reverts to disk-backed storage. For persistent RAM-only logging, add an fstab entry or create a systemd .mount unit manually.# Add to /etc/fstab for persistence across reboots:
tmpfs /var/log/tor tmpfs size=10M,mode=0700,uid=debian-tor,gid=debian-tor 0 0
sudo mount | grep tmpfs | grep tor # Should show the tmpfs mount sudo df -h /var/log/tor # Should show tmpfs filesystem
Traffic Analysis & Tracking Protection
Multiple independent layers defeat every known traffic correlation and fingerprinting technique. Even an observer watching both ends of the Tor circuit cannot correlate requests to your server.
Response Size Padding
A Lua script at the nginx body_filter_by_lua_file phase pads all HTTP responses to random block sizes using null bytes. An observer monitoring response sizes cannot distinguish page content from padding โ all responses look similar.
Timing Randomization
10โ50ms random delay is injected per response. Timing-correlation attacks that rely on consistent server latency โ even inside encrypted Tor circuits โ are defeated at the application layer before the response is sent.
Header Scrubbing
The following headers are removed entirely: Server, X-Powered-By, ETag, Last-Modified, X-Request-ID, X-Forwarded-For, Via. server_tokens off provides a second layer of version concealment. Fingerprinting the nginx version or platform from response headers is impossible.
Cache Prevention
Cache-Control: no-store, no-cache and Clear-Site-Data headers prevent browser-side caching that could be used for tracking across sessions.
Protection Matrix
# Response sizes should vary (random padding) for i in {1..5}; do curl -s -o /dev/null -w "%{size_download}\n" http://127.0.0.1/ done # No identifying headers should appear: curl -I http://127.0.0.1/ | grep -i "server\|etag\|last-modified\|x-powered"
Automated Privacy Compliance Monitor
A systemd timer that continuously verifies your privacy posture โ not just at install time, but throughout the life of the service.
| Parameter | Value |
|---|---|
| Timer unit | privacy-monitor.timer |
| Service unit | privacy-monitor.service (Type=oneshot) |
| Interval | Every 10 minutes |
| Boot delay | 2 minutes after boot |
| Script | /usr/local/bin/privacy_monitor.sh |
What it checks
- tmpfs RAM disk is still mounted at
/var/log/tor - nginx is not leaking
Serveror version identifiers in responses - Disk-backed log files that should not exist are flagged and removed
- Runs
privacy_log_sanitizer.pyto scrub IPs and hostnames from RAM log entries
sudo systemctl status privacy-monitor.timer sudo systemctl list-timers | grep privacy # See next run time sudo /usr/local/bin/privacy_monitor.sh # Run manually sudo journalctl -u privacy-monitor.service # View last run output
Maintenance Commands
Day-to-day commands for operating a live Aegis deployment.
sudo aegis-edit # Opens nano, fixes ownership, reloads nginx on save
sudo ./aegis_monitor.sh # Real-time threat and health dashboard
sudo journalctl -u tor@default -f # Live Tor log sudo tail -f /var/log/tor/notices.log # Tor notices (RAM) sudo tail -f /var/log/tor/sentry.log # Neural Sentry events sudo journalctl -u nginx -f # nginx
sudo nano /etc/nginx/sites-available/onion_site
sudo nginx -t # Always validate first
sudo systemctl reload nginx
sudo nano /etc/tor/torrc sudo systemctl restart tor@default
sudo tar -czf aegis-backup-$(date +%Y%m%d).tar.gz \
/var/lib/tor/hidden_service/ \
/etc/tor/torrc \
/etc/nginx/sites-available/onion_site \
/var/www/onion_site
sudo ./uninstall.sh
Common Issues & Fixes
Solutions to every known installation and runtime issue.
nginx fails โ unicode.mapping not found
Error: Failed to locate the unicode map file from: unicode.mapping
sudo wget https://raw.githubusercontent.com/SpiderLabs/ModSecurity/v3/master/unicode.mapping \
-O /etc/nginx/modsec/unicode.mapping
sudo sed -i "s|SecUnicodeMapFile unicode.mapping|SecUnicodeMapFile /etc/nginx/modsec/unicode.mapping|g" \
/etc/nginx/modsec/modsecurity.conf
sudo nginx -t && sudo systemctl restart nginx
Tor shows "active (exited)" on Debian 13
On Debian 13, tor.service is a dummy master unit (ExecStart=/bin/true). The real process is tor@default.service.
sudo systemctl status tor@default # Check the real unit
sudo systemctl restart tor@default
sudo cat /var/lib/tor/hidden_service/hostname
"Onion Site Not Found" in Tor Browser
Brand-new v3 addresses take 2โ5 minutes to propagate to HSDir nodes. This is normal.
sudo systemctl status tor@default nginx sudo cat /var/lib/tor/hidden_service/hostname # Verify address curl -v http://127.0.0.1/ # nginx responding locally?
SSH lockout after install
You answered No to SSH access on a VPS. Use your provider's web console (VNC/KVM), then:
sudo nft flush ruleset # Remove all firewall rules sudo ./install.sh # Re-run, answer Y to SSH
nginx fails โ Lua "undefined symbol: ndk_set_var_value"
Module load order issue. NDK must load before Lua.
sudo ln -sf /usr/share/nginx/modules-available/mod-http-ndk.conf \
/etc/nginx/modules-enabled/10-ndk.conf
sudo ln -sf /usr/share/nginx/modules-available/mod-http-lua.conf \
/etc/nginx/modules-enabled/20-lua.conf
sudo systemctl restart nginx
Hidden service not created after 60 seconds
sudo chown -R debian-tor:debian-tor /var/lib/tor/hidden_service sudo chmod 700 /var/lib/tor/hidden_service sudo systemctl restart tor@default sleep 15 && sudo cat /var/lib/tor/hidden_service/hostname
Important File Locations
Quick reference for every file path used by the Aegis stack.
Version History
Every significant change across the Aegis release history.
v10.0 Bare Metal Edition Current
- Docker removed permanently โ incompatible with sysctl hardening, NFTables, Tor Sandbox mode, and tmpfs RAM logging.
- detect_tor_service() โ reads
ExecStartproperty to distinguish Debian 13's dummytor.servicefrom the realtor@default.service. - INSTALL_DIR fix โ changed from
$(pwd)toBASH_SOURCE-based resolution. Works when called from any directory. - set -E โ ERR trap now fires inside functions and subshells. No silent failures.
- Privacy monitor systemd timer โ runs automatically every 10 minutes. No manual execution needed.
- Uninstaller updated โ removes all systemd units including privacy-monitor.timer, traffic-protection.service.
- unicode.mapping auto-download โ fixes nginx startup crash from missing SecUnicodeMapFile.
- Pre-firewall nginx validation โ nginx config verified before nftables applied, preventing lockout on bad config.
v9.0 Architect Edition
- Balanced NFTables โ replaced aggressive rate limiting with stateful
ct state established,related. Fixed "Onion Site Not Found" at launch. - SSH Safety Valve โ interactive prompt prevents VPS lockout during installation.
- Session HUD โ aegis_monitor.sh v5.0 with live CPU/RAM for Tor and nginx, real-time threat feed.
- Variable initialization โ fixed
unary operator expectedcrashes on strict bash installs.
v7/v8 Early Versions
- Dual Docker + bare metal deployment. Docker later removed due to fundamental incompatibilities.
- Neural Sentry v1โv4. Basic NFTables with aggressive rate limiting that caused Tor blockages.
- Manual privacy monitor โ users had to remember to run it.
Version Comparison
What Aegis Protects Against
Aegis is designed around a specific, realistic threat model. Understanding it helps you know exactly what is and is not protected.
Protected โ Server Side
- Traffic analysis via response size correlation
- Timing correlation attacks
- DNS leakage outside Tor
- Server fingerprinting via response headers
- Application-layer attacks (SQLi, XSS) via ModSecurity WAF
- DDoS / circuit flooding via Neural Sentry NEWNYM
- Forensic log analysis โ RAM-only logging, IP sanitization
- Memory dumps โ core dumps disabled
- Port scanning โ default DROP policy
- Cache-based tracking via cache-control headers
Out of Scope โ Client Side & Physical
- Browser fingerprinting โ JavaScript and client-side tracking are outside server control
- User behaviour โ typing patterns, mouse movements, session habits
- Tor guard node compromise โ a global adversary who controls the first hop
- Physical seizure โ hardware attacks, cold boot (mitigated but not eliminated by RAM logs)
- OPSEC failures โ publishing your address publicly, reusing identities, poor key management
Verification Report โ v10.0
Live deployment verified on Debian 13 Trixie. All components confirmed operational.
nginx active ยท tor@default active ยท ModSecurity WAF blocking ยท Onion address generated ยท Privacy Monitor running
install.shtor@default.serviceneural-sentry.serviceprivacy-monitor.timertraffic-protection.serviceuninstall.shv10.0 Bare Metal Edition ยท Debian 13 Trixie Verified