feat(proxy): NextWks proxies /auth/* to Authelia internally
This commit is contained in:
parent
95308c880b
commit
a8172324b7
1 changed files with 18 additions and 0 deletions
18
src/main.go
18
src/main.go
|
|
@ -7,6 +7,7 @@ import (
|
|||
"fmt"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
|
@ -107,6 +108,23 @@ func main() {
|
|||
// Setup HTTP router
|
||||
mux := http.NewServeMux()
|
||||
|
||||
// Reverse proxy: /auth/* → Authelia (except /auth/callback)
|
||||
autheliaProxy := httputil.NewSingleHostReverseProxy(&url.URL{
|
||||
Scheme: "http",
|
||||
Host: fmt.Sprintf("%s:%d", "127.0.0.1", 9091),
|
||||
})
|
||||
mux.HandleFunc("GET /auth/", func(w http.ResponseWriter, r *http.Request) {
|
||||
// Skip /auth/callback and /auth/login /auth/logout — handled by NextWks
|
||||
if r.URL.Path == "/auth/callback" || r.URL.Path == "/auth/login" || r.URL.Path == "/auth/logout" {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
autheliaProxy.ServeHTTP(w, r)
|
||||
})
|
||||
mux.HandleFunc("POST /auth/", func(w http.ResponseWriter, r *http.Request) {
|
||||
autheliaProxy.ServeHTTP(w, r)
|
||||
})
|
||||
|
||||
// --- Public endpoints ---
|
||||
mux.HandleFunc("GET /api/health", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
|
|
|||
Loading…
Reference in a new issue