@@ -133,16 +133,20 @@ func (p *Server) handleHTTP(w http.ResponseWriter, r *http.Request) {
133
133
}
134
134
135
135
// Forward regular HTTP request
136
- p .forwardHTTPRequest (w , r )
136
+ p .forwardRequest (w , r , false )
137
137
}
138
138
139
- // forwardHTTPRequest forwards a regular HTTP request
140
- func (p * Server ) forwardHTTPRequest (w http.ResponseWriter , r * http.Request ) {
139
+ // forwardRequest forwards a regular HTTP request
140
+ func (p * Server ) forwardRequest (w http.ResponseWriter , r * http.Request , https bool ) {
141
141
p .logger .Debug ("forwardHTTPRequest called" , "method" , r .Method , "url" , r .URL .String (), "host" , r .Host )
142
142
143
+ s := "http"
144
+ if https {
145
+ s = "https"
146
+ }
143
147
// Create a new request to the target server
144
148
targetURL := & url.URL {
145
- Scheme : "http" ,
149
+ Scheme : s ,
146
150
Host : r .Host ,
147
151
Path : r .URL .Path ,
148
152
RawQuery : r .URL .RawQuery ,
@@ -357,13 +361,21 @@ func (p *Server) handleTLSConnection(tlsConn *tls.Conn, hostname string) {
357
361
358
362
// handleDecryptedHTTPS handles decrypted HTTPS requests and applies rules
359
363
func (p * Server ) handleDecryptedHTTPS (w http.ResponseWriter , r * http.Request ) {
364
+ fullURL := r .URL .String ()
365
+ if r .URL .Host == "" {
366
+ // Fallback: construct URL from Host header
367
+ fullURL = fmt .Sprintf ("https://%s%s" , r .Host , r .URL .Path )
368
+ if r .URL .RawQuery != "" {
369
+ fullURL += "?" + r .URL .RawQuery
370
+ }
371
+ }
360
372
// Check if request should be allowed
361
- result := p .ruleEngine .Evaluate (r .Method , r . URL . String () )
373
+ result := p .ruleEngine .Evaluate (r .Method , fullURL )
362
374
363
375
// Audit the request
364
376
p .auditor .AuditRequest (audit.Request {
365
377
Method : r .Method ,
366
- URL : r . URL . String () ,
378
+ URL : fullURL ,
367
379
Allowed : result .Allowed ,
368
380
Rule : result .Rule ,
369
381
})
@@ -374,7 +386,7 @@ func (p *Server) handleDecryptedHTTPS(w http.ResponseWriter, r *http.Request) {
374
386
}
375
387
376
388
// Forward the HTTPS request (now handled same as HTTP after TLS termination)
377
- p .forwardHTTPRequest (w , r )
389
+ p .forwardRequest (w , r , true )
378
390
}
379
391
380
392
// handleConnectionWithTLSDetection detects TLS vs HTTP and handles appropriately
0 commit comments