Try simulating caddy forward_auth

This commit is contained in:
cheddar 2025-02-16 13:51:53 -05:00
parent 1af1d774d3
commit 65934ea570
No known key found for this signature in database
3 changed files with 56 additions and 14 deletions

20
server/caddy_rewrite.go Normal file
View file

@ -0,0 +1,20 @@
package server
import (
"fmt"
"net/http"
)
func rewriteHeaders(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
forwardedMethod := r.Header.Get("X-Forwarded-Method")
forwardedUri := r.Header.Get("X-Forwarded-Uri")
fmt.Printf("Headers: %s, %s\n", forwardedMethod, forwardedUri)
r.Method = forwardedMethod
r.RequestURI = forwardedUri
next.ServeHTTP(w, r)
})
}