From 8561f59beb7d57b682dfdc2f7fe27551f30effce Mon Sep 17 00:00:00 2001 From: cclohmar Date: Fri, 10 Jul 2026 15:26:46 +0100 Subject: [PATCH] fix: use container names instead of static IPs --- compose/authelia.yaml | 3 +-- compose/caddy.yaml | 3 +-- compose/launcher.yaml | 5 +---- main.go | 12 ++++++------ 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/compose/authelia.yaml b/compose/authelia.yaml index 90823fc..ebd8870 100644 --- a/compose/authelia.yaml +++ b/compose/authelia.yaml @@ -10,8 +10,7 @@ services: - /opt/nextworkspace/config/authelia/:/config/ - /opt/nextworkspace/data/authelia/:/data/ networks: - nextwks-net: - ipv4_address: 172.16.0.11 + - nextwks-net networks: nextwks-net: diff --git a/compose/caddy.yaml b/compose/caddy.yaml index f6f4d2e..7e205ad 100644 --- a/compose/caddy.yaml +++ b/compose/caddy.yaml @@ -12,8 +12,7 @@ services: - /opt/nextworkspace/logs/caddy/:/var/log/caddy/ - /opt/nextworkspace/www/:/opt/nextworkspace/www/ networks: - nextwks-net: - ipv4_address: 172.16.0.10 + - nextwks-net networks: nextwks-net: diff --git a/compose/launcher.yaml b/compose/launcher.yaml index 03cc083..1d8c12e 100644 --- a/compose/launcher.yaml +++ b/compose/launcher.yaml @@ -7,16 +7,13 @@ services: - "9000" volumes: - /opt/nextworkspace/:/opt/nextworkspace/ - - /opt/nextworkspace/data/:/opt/nextworkspace/data/ - - /opt/nextworkspace/lng/:/opt/nextworkspace/lng/ - /opt/nextworkspace/.env:/opt/nextworkspace/.env working_dir: /opt/nextworkspace command: /opt/nextworkspace/nextworkspace environment: - CONFIG_DIR=/opt/nextworkspace/config/nextworkspace networks: - nextwks-net: - ipv4_address: 172.16.0.12 + - nextwks-net networks: nextwks-net: diff --git a/main.go b/main.go index ff308e2..4d406bc 100644 --- a/main.go +++ b/main.go @@ -303,7 +303,7 @@ func proxyToUpstream(upstream string) http.HandlerFunc { } func adminHandler(w http.ResponseWriter, r *http.Request) { - apiBase := "http://172.16.0.11:8080" + apiBase := "http://authelia:8080" apiToken := os.Getenv("AUTHELIA_SECRET") configDir := os.Getenv("CONFIG_DIR") if configDir == "" { @@ -348,13 +348,13 @@ func adminHandler(w http.ResponseWriter, r *http.Request) { // Check service statuses autheliaUp := false - if resp, err := http.Get("http://172.16.0.11:9091/api/health"); err == nil { + if resp, err := http.Get("http://authelia:9091/api/health"); err == nil { autheliaUp = resp.StatusCode == 200 resp.Body.Close() } caddyUp := false // Check port 80 responds (don't follow HTTPS redirect) - if conn, err := net.DialTimeout("tcp", "172.16.0.10:80", 3*time.Second); err == nil { + if conn, err := net.DialTimeout("tcp", "caddy:80", 3*time.Second); err == nil { caddyUp = true conn.Close() } @@ -511,7 +511,7 @@ type apiUser struct { func fetchAllUsers() ([]apiUser, error) { apiToken := os.Getenv("AUTHELIA_SECRET") - req, _ := http.NewRequest("GET", "http://172.16.0.11:8080/api/users", nil) + req, _ := http.NewRequest("GET", "http://authelia:8080/api/users", nil) req.Header.Set("Authorization", "Bearer "+apiToken) resp, err := http.DefaultClient.Do(req) if err != nil { @@ -608,7 +608,7 @@ func initials(s string) string { // --- API proxy for authelia-api --- func apiProxyHandler(w http.ResponseWriter, r *http.Request) { - target, _ := url.Parse("http://172.16.0.11:8080") + target, _ := url.Parse("http://authelia:8080") proxy := httputil.NewSingleHostReverseProxy(target) // Inject Bearer token for authelia-api auth token := os.Getenv("AUTHELIA_SECRET") @@ -638,7 +638,7 @@ func globalSettingsHandler(w http.ResponseWriter, r *http.Request) { // Check Authelia health autheliaUp := false - if resp, err := http.Get("http://172.16.0.11:9091/api/health"); err == nil { + if resp, err := http.Get("http://authelia:9091/api/health"); err == nil { autheliaUp = resp.StatusCode == 200 resp.Body.Close() }