Technology
The proxy module provides secure HTTP proxy functionality for Project Forge applications. It allows your application to proxy requests to external services while maintaining security controls and consistent routing patterns.
Overview
This module enables applications to act as a secure HTTP proxy, forwarding requests to configured external services while:
- Enforcing Security: Maintains your application’s authentication and authorization
- URL Rewriting: Automatically rewrites relative URLs in responses to maintain proper routing
- Header Management: Filters and manages HTTP headers for security
- Service Management: Dynamically register and manage proxy destinations
⚠️ Security Notice: This module is marked as “dangerous” as it can expose your application to external services. Use with proper authentication and validation.
Key Features
Secure Proxying
- Filters dangerous HTTP headers (Connection, Keep-Alive, etc.)
- Adds “Proxied” header to identify proxy requests
- Maintains request context and logging
URL Rewriting
- Automatically rewrites
href="/..."andsrc="/..."attributes - Ensures proxied content links work correctly within your application
- Maintains relative path integrity
Dynamic Service Management
- Register and remove proxy destinations at runtime
- List all configured proxy services
- Per-service URL configuration
Configuration
The proxy service is initialized with:
1 | |
Usage
Basic Setup
- Initialize the service in your application startup:
proxy := proxy.NewService("/proxy", initialProxies)
- Wire up routes in your router configuration:
1 | |
Managing Proxy Services
1 | |
Request Flow
- Client makes request to
/proxy/{service}/{path} - Proxy service looks up the target URL for
{service} - Request is forwarded to
{target_url}/{path} - Response is processed and URLs are rewritten
- Modified response is returned to client
Security Considerations
- Authentication: Proxy requests should be authenticated through your application’s normal auth flow
- Authorization: Consider implementing service-specific access controls
- Input Validation: Validate service names and paths to prevent abuse
- Network Access: Ensure proxied services are on trusted networks
- Header Filtering: The module filters dangerous headers but review for your specific needs
Source Code
- Repository: https://github.com/kyleu/projectforge/tree/main/module/proxy
- License: CC0 (Public Domain)
- Author: Kyle U (kyle@kyleu.com)
See Also
- HTTP Security Best Practices
- Project Forge Documentation - Complete documentation
- Configuration Variables - Available environment variables