fix: use container names instead of static IPs
This commit is contained in:
parent
7e12e8d831
commit
8561f59beb
4 changed files with 9 additions and 14 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
12
main.go
12
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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue