htmonitor

# ๐ŸŒ .htaccess Geo-Redirection Mock/Testing [![Version](https://img.shields.io/badge/version-1.0.0-blue.svg)](https://github.com/spagu/htmonitor) [![Go Version](https://img.shields.io/badge/go-1.24+-00ADD8.svg)](https://golang.org/) [![Python Version](https://img.shields.io/badge/python-3.8+-3776ab.svg)](https://www.python.org/) [![Docker](https://img.shields.io/badge/docker-ready-2496ED.svg)](https://www.docker.com/) [![License](https://img.shields.io/badge/license-Commercial-red.svg)](LICENSE) [![Lint](https://github.com/spagu/htmonitor/actions/workflows/lint.yml/badge.svg)](https://github.com/spagu/htmonitor/actions/workflows/lint.yml) [![Release](https://github.com/spagu/htmonitor/actions/workflows/release.yml/badge.svg)](https://github.com/spagu/htmonitor/actions/workflows/release.yml) [![Tests](https://img.shields.io/badge/tests-24%20passing-brightgreen.svg)](apps/htaccess-monitor/TEST_README.md) [![Coverage](https://img.shields.io/badge/coverage-19.5%25-yellow.svg)](apps/htaccess-monitor/TEST_README.md) [![Code Quality](https://img.shields.io/badge/code%20quality-A-brightgreen.svg)](https://github.com/spagu/htmonitor) [![WCAG 2.2](https://img.shields.io/badge/WCAG-2.2%20AA-green.svg)](https://www.w3.org/WAI/WCAG22/quickref/) ๐Ÿš€ **Real-time Monitoring** โ€ข ๐Ÿงช **Multi-Country Testing** โ€ข ๐Ÿค– **Google Bot Spoofing** โ€ข ๐Ÿณ **Docker Ready** A comprehensive monorepo containing tools and applications for testing geo-redirection rules, Google Bot spoofing, and website availability across multiple countries. [๐Ÿš€ Quick Start](#-installation) โ€ข [๐Ÿ“– Documentation](#-usage) โ€ข [๐Ÿ—๏ธ Architecture](#-architecture) โ€ข [๐Ÿค Contributing](#-contributing) ---

โœจ Key Features

Go Monitoring
๐Ÿ–ฅ๏ธ Go Monitor
Live .htaccess file watching with beautiful terminal UI
Python Testing
๐Ÿ Python Tester
Comprehensive testing across 14+ countries
Docker
๐Ÿณ Docker Setup
Containerized Apache with GeoIP simulation

๐Ÿš€ Applications

Realtime-Monitor Realtime-Monitor

1. htaccess-monitor (Go)

Real-time terminal UI application that monitors .htaccess file changes and automatically tests geo-redirection rules.

Features:

2. python-tester (Python)

Comprehensive testing suite with multiple Google Bot user agents and detailed analysis. Simple test bash Features:

3. docker-setup (Docker)

Complete Docker environment for testing geo-redirection rules.

Features:

๐ŸŽฏ Supported Countries

| Flag | Country | Code | Redirect Path | Status | |------|---------|------|---------------|--------| | ๐Ÿ‡บ๐Ÿ‡ธ | United States | US | No redirect | โœ… Default | | ๐Ÿ‡ฌ๐Ÿ‡ง | United Kingdom | UK | `/uk/` | ๐Ÿ”„ Active | | ๐Ÿ‡ฆ๐Ÿ‡บ | Australia | AU | `/au/` | ๐Ÿ”„ Active | | ๐Ÿ‡ฆ๐Ÿ‡น | Austria | AT | `/at/` | ๐Ÿ”„ Active | | ๐Ÿ‡จ๐Ÿ‡ฆ | Canada | CA | `/ca/` | ๐Ÿ”„ Active | | ๐Ÿ‡ซ๐Ÿ‡ท | France | FR | `/fr/` | ๐Ÿ”„ Active | | ๐Ÿ‡ฉ๐Ÿ‡ช | Germany | DE | `/de/` | ๐Ÿ”„ Active | | ๐Ÿ‡ฎ๐Ÿ‡ช | Ireland | IE | `/ie/` | ๐Ÿ”„ Active | | ๐Ÿ‡ฎ๐Ÿ‡น | Italy | IT | `/it/` | ๐Ÿ”„ Active | | ๐Ÿ‡จ๐Ÿ‡ญ | Switzerland | CH | `/ch/` | ๐Ÿ”„ Active | | ๐Ÿ‡ช๐Ÿ‡ธ | Spain | ES | `/es/` | ๐Ÿ”„ Active | | ๐Ÿ‡ฑ๐Ÿ‡บ | Luxembourg | LU | `/fr/` | ๐Ÿ”„ Active | | ๐Ÿ‡ฑ๐Ÿ‡ฎ | Liechtenstein | LI | `/ch/` | ๐Ÿ”„ Active | | ๐Ÿ‡ฏ๐Ÿ‡ต | Japan | JP | `/uk/` | ๐Ÿ”„ Active | **Total Coverage:** 14 countries with comprehensive geo-redirection testing

๐Ÿ“‹ Prerequisites

๐Ÿš€ Installation simple

  1. run make docker-start
  2. run make go-binary (downloads pre-built binary)
  3. edit .htaccess file at .htaccess

๐Ÿš€ Installation advanced

  1. Clone the repository:
    git clone https://github.com/tradik/htmonitor.git
    cd red
    
  2. Install dependencies: ```bash

    Download pre-built binary (recommended)

    make go-binary

OR build from source

make go-build

Go dependencies (if building from source)

cd apps/htaccess-monitor && go mod tidy

Python dependencies

pip install -r apps/python-tester/requirements.txt


3. Start services:
```bash
# Start Docker environment
make docker-start

# Run the monitor
make go-run

๐Ÿ“– Usage

๐Ÿ–ฅ๏ธ Go Monitor (Real-time UI)

Start the real-time terminal monitor:

make go-run

The Go monitor can also watch your link scenarios and .htaccess and automatically re-run tests whenever those files change.

Run via Makefile:

make go-test-watch

Or run directly:

cd apps/htaccess-monitor
# Watch links.testing and .htaccess, re-run on changes
LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 \
  go run main.go -test ../../links.testing -watch

Controls

CSV schema (links.testing)

Agent, Country, URL, Expected status, Expected result
Browser, US, http://localhost:8080/ , 200, No redirect
Googlebot, UK, http://localhost:8080/ , 200, No redirect
Browser, FR, http://localhost:8080/uk , 301, http://localhost:8080/uk/

Matching rules

Flow

sequenceDiagram
    participant E as Editor
    participant W as fsnotify Watcher
    participant R as Test Runner
    participant V as Terminal View
    E->>W: Save links.testing or .htaccess
    W-->>R: File change event (debounced 500ms)
    R->>R: Parse CSV + run HTTP tests
    R-->>V: Results (pass/fail, redirects)
    V->>V: Render ANSI-aware table, filters applied

Tips

๐Ÿ“ฅ Binary Download Options

The make go-binary command uses GitHub CLI to download pre-built binaries:

# Auto-detect system architecture (default: linux-amd64)
make go-binary

# Specify custom architecture
ARCH=darwin-arm64 make go-binary
ARCH=windows-amd64.exe make go-binary

# Specify version
VERSION=1.1.0 make go-binary

# List available architectures
./scripts/download-binary.sh --list

Requirements:

Supported platforms:

Controls:

๐Ÿ Python Testing Suite

Basic Usage:

# Test localhost with default settings
cd apps/python-tester
python googlebot_spoof_tester.py --url http://localhost:8080

# Test with all Google Bot types
python googlebot_spoof_tester.py --url http://localhost:8080 --all-bots

Advanced Usage:

# Custom timeout and delay settings
python googlebot_spoof_tester.py --url http://localhost:8080 --timeout 60 --delay 2.0

# Save results to specific file
python googlebot_spoof_tester.py --url http://localhost:8080 --output test_results.json

# Run fancy bash script with country flags
./test_all_languages.sh

๐Ÿณ Docker Environment

Setup and run:

# Start Docker environment
cd apps/docker-setup
docker-compose up -d

# View logs
docker-compose logs -f

# Stop environment
docker-compose down

Test URLs:

๐Ÿงช Using the Docker mock server (curl cheatsheet)

The Dockerized Apache exposes the site at http://localhost:8080/ and simulates GeoIP via the X-Test-Country HTTP header. You can also spoof the Googlebot user agent with -A.

Quick checks (headers only):

# Check redirect behavior for US visiting /uk and /uk/
curl -s -I -H "X-Test-Country: US" "http://localhost:8080/uk/" | grep -E "(HTTP|Location)"
curl -s -I -H "X-Test-Country: US" "http://localhost:8080/uk" | grep -E "(HTTP|Location)"

# Simulate Googlebot from DE (Germany) hitting root and /uk/
curl -s -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" -H "X-Test-Country: DE" "http://localhost:8080/" && echo ""
curl -s -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" -H "X-Test-Country: DE" "http://localhost:8080/uk/" && echo ""
curl -s -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" -H "X-Test-Country: DE" "http://localhost:8080/uk/"

Notes:

๐Ÿ“Š Test Results

Status Indicators

Special Test Cases

๐Ÿ—๏ธ Architecture

graph TB
    A[Go Monitor] --> B[.htaccess Watcher]
    A --> C[HTTP Test Runner]
    
    D[Python Tester] --> E[Google Bot Spoofer]
    D --> F[Multi-Country Tests]
    
    G[Docker Setup] --> H[Apache Server]
    G --> I[GeoIP Mock]
    
    J[Shared Packages] --> K[.htaccess Rules]
    J --> L[GeoIP Mock Service]
    
    B --> K
    C --> H
    E --> H
    F --> H

๐ŸŽจ Style Guidelines

Colors and Contrast

UI Components

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Development Guidelines

Testing

The Go application includes comprehensive test coverage:

# Run unit tests
make go-test

# Run with coverage report
make go-test-coverage

# Run integration tests
make go-test-integration

# Run benchmarks
make go-test-bench

# Run all tests
make go-test-all

Test Coverage: 19.5% of statements (focused on business logic)

For detailed testing documentation, see apps/htaccess-monitor/TEST_README.md

CI/CD

Automated workflows ensure code quality and streamlined releases:

๐Ÿ” Lint Workflow (on push/PR to main/develop)

๐Ÿš€ Release Workflow (on merge to main)

For workflow details, see .github/workflows/README.md

๐Ÿ“„ License

This project is licensed under a Commercial License - see the LICENSE file for details.

Copyright 2025 Tradik Limited. All rights reserved.

This software is proprietary and confidential. Unauthorized copying, distribution, or use is strictly prohibited. For licensing inquiries, contact: legal@tradik.com

๐Ÿ†˜ Troubleshooting

Common Issues

Go Monitor not starting:

cd apps/htaccess-monitor
go mod tidy
go run main.go

Python tests failing:

cd apps/python-tester
pip install -r requirements.txt
python googlebot_spoof_tester.py --url http://localhost:8080

Docker services not accessible:

cd apps/docker-setup
docker-compose down
docker-compose up -d

Logs and Debugging

๐Ÿ—๏ธ Monorepo Structure

red/
โ”œโ”€โ”€ apps/                           # Main applications
โ”‚   โ”œโ”€โ”€ htaccess-monitor/          # Go terminal UI monitor
โ”‚   โ”‚   โ”œโ”€โ”€ main.go
โ”‚   โ”‚   โ”œโ”€โ”€ go.mod
โ”‚   โ”‚   โ”œโ”€โ”€ go.sum
โ”‚   โ”‚   โ””โ”€โ”€ README.md
โ”‚   โ”œโ”€โ”€ python-tester/             # Python testing suite
โ”‚   โ”‚   โ”œโ”€โ”€ googlebot_spoof_tester.py
โ”‚   โ”‚   โ”œโ”€โ”€ test_all_languages.sh
โ”‚   โ”‚   โ”œโ”€โ”€ requirements.txt
โ”‚   โ”‚   โ””โ”€โ”€ README.md
โ”‚   โ”œโ”€โ”€ docker-setup/              # Docker configuration
โ”‚   โ”‚   โ”œโ”€โ”€ Dockerfile
โ”‚   โ”‚   โ”œโ”€โ”€ docker-compose.yml
โ”‚   โ”‚   โ”œโ”€โ”€ apache-vhost.conf
โ”‚   โ”‚   โ””โ”€โ”€ README.md
โ”‚   โ””โ”€โ”€ test-scripts/              # Testing utilities
โ”‚       โ””โ”€โ”€ test-countries.sh
โ”œโ”€โ”€ packages/                       # Shared packages
โ”‚   โ””โ”€โ”€ shared/                    # Common configurations
โ”‚       โ”œโ”€โ”€ .htaccess              # Geo-redirection rules
โ”‚       โ”œโ”€โ”€ geoip-mock.php         # GeoIP mock service
โ”‚       โ””โ”€โ”€ README.md
โ”œโ”€โ”€ docs/                           # Documentation
โ”‚   โ”œโ”€โ”€ ARCHITECTURE.md            # System architecture
โ”‚   โ”œโ”€โ”€ HTACCESS_DOCUMENTATION.md  # .htaccess guide
โ”‚   โ””โ”€โ”€ README-DOCKER.md           # Docker setup guide
โ”œโ”€โ”€ logs/                           # Application logs
โ”‚   โ”œโ”€โ”€ access.log
โ”‚   โ”œโ”€โ”€ error.log
โ”‚   โ””โ”€โ”€ other_vhosts_access.log
โ”œโ”€โ”€ Makefile                        # Build automation
โ”œโ”€โ”€ CHANGELOG.md                    # Version history
โ”œโ”€โ”€ workspace.json                  # Workspace configuration
โ””โ”€โ”€ README.md                       # This file

** 2025 Tradik Limited - Commercial License** Made with โค๏ธ for geo-redirection testing

See CHANGELOG.md for version history and updates.