| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package reverseproxy
- import (
- "time"
- )
- const (
- DefaultConfigPath = "/etc/debtik/reverse_proxy.json"
- ProtocolHTTP = "http"
- ProtocolHTTPS = "https"
- ProtocolBoth = "both"
- )
- // RuleStats holds runtime counters for a proxy rule.
- type RuleStats struct {
- Requests uint64 `json:"requests"`
- BytesReceived uint64 `json:"bytes_received"`
- BytesSent uint64 `json:"bytes_sent"`
- LastAccess time.Time `json:"last_access,omitempty"`
- }
- // Rule represents a single routing rule for the reverse proxy.
- type Rule struct {
- ID string `json:"id"`
- Name string `json:"name"`
- Enabled bool `json:"enabled"`
- Domains []string `json:"domains"` // Hostnames or IPs to match (e.g. "example.com", "app.local", "*")
- Path string `json:"path"` // Inbound path prefix to match (e.g. "/" or "/app1")
- TargetURL string `json:"target_url"` // Backend target URL (e.g. "http://example.com/app1" or "http://10.0.0.5:8080")
- StripPath bool `json:"strip_path"` // Whether to strip the inbound path prefix before forwarding
- PreserveHost bool `json:"preserve_host"` // If true, forward client Host header; else use TargetURL host
- Protocol string `json:"protocol"` // "http", "https", "both"
- Certificate string `json:"certificate,omitempty"` // Certificate name from CertManager for TLS/HTTPS
- HTTPToHTTPS bool `json:"http_to_https"` // Auto-redirect HTTP to HTTPS for this rule
- InsecureTLS bool `json:"insecure_tls"` // Skip TLS verification for backend HTTPS targets
- CustomHeaders map[string]string `json:"custom_headers,omitempty"` // Custom HTTP headers to inject
- Comment string `json:"comment,omitempty"` // User description
- CreatedAt time.Time `json:"created_at"`
- UpdatedAt time.Time `json:"updated_at"`
- Stats RuleStats `json:"stats"`
- }
- // Config represents global reverse proxy configuration.
- type Config struct {
- Enabled bool `json:"enabled"`
- HTTPPort int `json:"http_port"` // Inbound HTTP port (default: 80)
- HTTPSPort int `json:"https_port"` // Inbound HTTPS port (default: 443)
- DefaultCert string `json:"default_cert,omitempty"` // Fallback certificate name
- Rules []*Rule `json:"rules"`
- }
|