Implementation Summary
Project Overview
This project delivers a complete Traefik middleware plugin enabling static site hosting for Forgejo/Gitea repositories, functioning similarly to GitHub Pages and GitLab Pages.
Version: v0.0.1 (current: v0.0.6) Repository: code.squarecows.com/SquareCows/pages-server Status: Production ready
Core Components
Main Plugin (pages.go)
Traefik middleware interface providing:
- HTTP-to-HTTPS redirection
- Request parsing
- Content caching
- Error page support
- Custom domain handling
- Password protection
Forgejo Client (forgejo_client.go)
API integration for:
- Repository verification
- File retrieval
- Configuration parsing
- Authentication handling
Caching System (cache.go)
Features include:
- In-memory TTL-based cache
- Redis distributed caching
- Concurrent safety
- Automatic expiration
- Connection pooling
Test Coverage & Documentation
The project provides:
- 56.3% test coverage across 47+ test cases
- Comprehensive README and configuration guides
- Example implementations
- API documentation
- Troubleshooting guides
Key Features
Static Site Hosting
- Serve from
public/folders - Repository validation via
.pagesfiles - Profile site support
- Directory indexing
Security & Performance
- HTTPS enforcement
- Private repository access via API tokens
- Caching with sub-5ms response targets
- Password protection with SHA256 hashing
Customisation
- Custom domain configuration
- Configurable error pages
- Flexible caching strategies
- Authentication options
Technology Stack
Core Technologies
- Language: Go 1.23+
- Framework: Traefik v2.0+ plugin system
- Interpreter: Yaegi for plugin execution
- API: Forgejo/Gitea REST APIs
Architecture
[Request] → [Traefik] → [pages-server Plugin] → [Forgejo API]
↓
[Cache Layer]
(Memory/Redis)
Components:
- Request handlers
- In-memory or Redis cache
- API clients
- Configuration management
Configuration
Minimal Setup
Required parameters:
pagesDomain: pages.example.com
forgejoHost: https://git.example.com
Optional Settings
- Authentication tokens
- Error page repositories
- Redis configuration
- Custom domain settings
- Password protection
- Cookie management
Deployment Status
The project meets all core requirements:
- ✅ Comprehensive testing
- ✅ Complete documentation
- ✅ Production-ready
- ✅ Semantic versioning
- ✅ MIT licensing
Feature Roadmap
v0.0.6 (Current)
- Password protection
- Redis binary data fixes
- Directory indexing
- HTTP headers (Server, X-Cache-Status)
- Persistent custom domains
Future Enhancements
Potential future features:
- Multiple custom domains per repository
- Advanced caching strategies
- Enhanced monitoring
- Additional authentication methods
- Performance optimisations
Architecture Decisions
Why Go Standard Library Only?
Ensures compatibility with Traefik’s Yaegi interpreter without external dependencies.
Why Redis Optional?
Supports both single-server and distributed deployments with automatic fallback.
Why SHA256 for Passwords?
Balances security with simplicity for static site use cases.
Performance Targets
Response Times
- Cache Hit: < 5ms
- Cache Miss: < 100ms
- Redis Operations: < 1ms
- API Calls: < 200ms
Throughput
- Handles 1000+ requests/second
- Connection pool management
- Efficient resource utilisation
Security Considerations
Authentication
- API token support
- Password hashing
- Secure cookie handling
- HTTPS enforcement
Access Control
- Repository visibility respect
- Private repository protection
- Authentication verification
- Permission checking
Monitoring & Observability
HTTP Headers
Server: bovine- Identifies the serverX-Cache-Status: HIT|MISS- Cache performance
Logging
- Request logging
- Error tracking
- Performance metrics
- Debug information
Contributing
The project welcomes contributions:
- Bug reports
- Feature requests
- Pull requests
- Documentation improvements
Visit the repository to contribute.
License
MIT License - See repository for full details.