feat(proxy): Add reverse proxy feature

This commit is contained in:
Björn Benouarets
2026-02-05 23:58:47 +01:00
parent 07474afae9
commit 30adf0c701
20 changed files with 514 additions and 323 deletions

41
app/server/host.go Normal file
View File

@@ -0,0 +1,41 @@
package server
import (
"net/http/httputil"
"net/url"
"git.secnex.io/secnex/api-gateway/config"
)
type Hosts map[string]*Host
type Host struct {
ID string
Name string
Domain string
proxy *httputil.ReverseProxy
}
func NewHosts(cfg *config.Configuration) Hosts {
hosts := make(Hosts)
for _, host := range cfg.Hosts {
hosts[host.ID] = NewHost(&host)
}
return hosts
}
func NewHost(host *config.Host) *Host {
return &Host{
ID: host.ID,
Name: host.Name,
Domain: host.Domain,
proxy: httputil.NewSingleHostReverseProxy(&url.URL{
Scheme: "https",
Host: host.Domain,
}),
}
}
func (hs Hosts) GetHost(domain string) *Host {
return hs[domain]
}