Tor Shared Hosting
A Tor-based shared hosting platform with PHP, MySQL, SFTP, email, and web-based management. Fork of DanWin/hosting with Debian 13 support, PHP 8.4/8.5, security hardening, and automated installation.
Features
- PHP 8.2, 8.3, 8.4, 8.5 (user-selectable from dashboard)
- Nginx, MariaDB, Dovecot, Postfix, ClamAV, Rspamd
- phpMyAdmin, Adminer, SquirrelMail webmail
- SFTP and SSH shell access per user
- Web-based file manager
- PGP-based two-factor authentication
- Per-user .onion domains and optional clearnet domains
- Auto-scaling Tor instances (1 per ~250 accounts)
- Vanity .onion address generation via mkp224o
- Zero JavaScript — all pages work without JS
- Security hardened (CSP, CSRF, XSS protection, encrypted keys at rest)
Requirements
- OS: Debian 13 (Trixie) or Ubuntu 24.04 LTS
- Production: 1TB SSD, 32GB RAM, 8 CPU cores
- Testing/Personal: 20GB disk, 4GB RAM, 1 CPU core
Quick Install
One-liner (downloads and runs the installer):
curl -sSL https://raw.githubusercontent.com/bigbong420/hosting/upgrades/install.sh | bash
Non-interactive with random passwords:
curl -sSL https://raw.githubusercontent.com/bigbong420/hosting/upgrades/install.sh | bash -s -- --non-interactive
With vanity .onion address:
curl -sSL https://raw.githubusercontent.com/bigbong420/hosting/upgrades/install.sh | bash -s -- --non-interactive --vanity mysite
Manual Install
git clone -b upgrades https://github.com/bigbong420/hosting.git
cd hosting
./install.sh
Install Options
./install.sh [OPTIONS]
--non-interactive Skip all prompts, generate random passwords
--skip-binaries Skip compiling PHP/ImageMagick (use if already built)
--vanity <prefix> Generate a vanity .onion address (a-z, 2-7 only)
--vanity-threads <n> Threads for vanity generation (default: nproc)
--db-pass <pass> Set hosting MySQL password
--pma-pass <pass> Set phpMyAdmin MySQL password
--admin-pass <pass> Set admin panel password
Vanity generation times (approximate):
| Prefix length | Time |
|---|---|
| 3 chars | seconds |
| 4 chars | minutes |
| 5 chars | 10-30 minutes |
| 6 chars | hours |
| 7+ chars | days |
Updating
cd /root/hosting
./update.sh # Update code, preserve config
./update.sh --rebuild # Also rebuild PHP/ImageMagick
./update.sh --code-only # Only update PHP files
The update script automatically detects if install_binaries.sh changed and warns you to rebuild.
Auto-Scaling
Tor instances scale automatically based on account count (~250 accounts per instance). The hosting-autoscale.timer checks hourly and adds instances as needed. Instance IDs go a through z, then aa, ab, etc.
Translation
Translations are managed in Weblate. The script update-translations.sh updates language templates. New translations go in var/www/YOUR_LANG_CODE/LC_MESSAGES/hosting.po.
Manual Configuration
After install, you can customize:
/var/www/common.php— all settings (DB, passwords, PHP versions, features)/etc/postfix/main.cf— mail configuration/etc/nginx/sites-enabled/default— web server config (auto-generated bysetup.php)
For clearnet domains, add to relay_domains in /etc/postfix/main.cf and edit:
/var/www/common.php/etc/postfix/canonical/etc/postfix-clearnet/canonical
For a second postfix instance (clearnet mail relay):
postmulti -e init
postmulti -I postfix-clearnet -e create
postmulti -i clearnet -e enable
postmulti -i clearnet -p start
Security
- CSRF tokens use
random_bytes(32) - Admin password stored as bcrypt hash
- Session regeneration on login
- All output escaped with
htmlspecialchars() - Nginx rewrite rules validated against injection
- Onion private keys encrypted at rest (libsodium)
- SFTP passwords encrypted in session with 1hr expiry
- Admin login rate-limited (exponential backoff)
- Content Security Policy:
script-src 'none' - No JavaScript anywhere
Architecture
/var/www/common.php — shared config and functions
/var/www/html/ — web interface (register, login, dashboard, admin)
/var/www/setup.php — database schema + service provisioning
/var/www/cron.php — account provisioning (runs every minute)
/var/www/autoscale.php — instance scaling (runs hourly)
/etc/systemd/system/ — PHP-FPM, Tor, timer service files
/etc/nginx/ — web server config
/etc/tor/ — Tor config
/etc/postfix/ — mail config
TODO: Multi-Server / Clustering
- Database replication — MariaDB primary-replica setup for read scaling and failover
- Shared storage — GlusterFS or CephFS for
/homeacross nodes so user files are accessible from any server - Load balancer — HAProxy or nginx stream proxy in front of multiple Tor-facing nodes
- Centralized config — move
common.phpsettings to a shared database or etcd so config changes propagate to all nodes - Cross-node instance assignment — extend
get_new_tor_instance()to assign accounts to instances across multiple servers based on load - Distributed autoscale — autoscale.php should track per-server capacity and spin up instances on the least-loaded server
- Session sharing — Redis-based PHP sessions so users can hit any node
- Mail routing — single Postfix relay that routes to the correct node based on account location
- Health monitoring — centralized health checks across nodes (service status, disk, Tor circuit health)
- Rolling updates — update.sh should support updating one node at a time with traffic draining
- Onion key migration — tool to move an account (onion keys, files, databases) between servers
- Shared ClamAV/Rspamd — run scanning services on dedicated nodes instead of every hosting node
- Backup orchestration — coordinated backups across nodes with point-in-time recovery
License
See COPYING for license information.