A Node.js application that provides domain randomization and redirection based on configurable rules. When accessed through specific domains, it generates random subdomains and redirects to configured target domains based on predefined rules.
- Domain-specific redirection rules
- Random subdomain generation
- RESTful API for managing domains and rules
- MariaDB integration for persistent storage
- Configurable through environment variables
- Comprehensive logging of all redirects
- Node.js (v18 or higher)
- MariaDB (v10.5 or higher)
- npm or yarn
- Clone the repository:
git clone https://github.com/arcestia/domain-randomizer.git
cd domain-randomizer- Install dependencies:
npm install- Create and configure the
.envfile:
cp .env.example .env
# Edit .env with your database credentials and settings- Set up the database:
mysql -u root < schema.sqlConfigure the application through the .env file:
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=
DB_NAME=domainrandomizer
DB_PORT=3306
PORT=3000- Start the server:
npm start- The application will handle incoming requests based on the hostname used to access it.
Example:
- Access through
domainA.com→ Redirects to random subdomain on eitherTargetA.comorTargetB.com - Access through
domainB.com→ Redirects to random subdomain on eitherTargetC.comorTargetD.com
See API.md for detailed API documentation.
Quick API examples:
- List all source domains:
curl http://localhost:3000/api/sources- Add new target domain:
curl -X POST http://localhost:3000/api/targets \
-H "Content-Type: application/json" \
-d '{"domain": "example.com"}'- Create new rule:
curl -X POST http://localhost:3000/api/rules \
-H "Content-Type: application/json" \
-d '{
"source_domain": "source.com",
"target_domain": "target.com"
}'The application uses four main tables:
source_domains: Stores domains that can access the servicetarget_domains: Stores potential redirect target domainsdomain_rules: Maps relationships between source and target domainsredirects: Logs all redirections for tracking
- Clone the repository
- Install dependencies:
npm install - Create
.envfile with your configuration - Set up the database using
schema.sql - Run the application:
npm start
- Protect your
.envfile - never commit it to version control - Implement proper authentication for API endpoints in production
- Use HTTPS for all production traffic
- Regularly backup your database
- Monitor redirect logs for abuse
Laurensius Jeffrey
© Skiddle ID 2025
Licensed under MIT