From fb16e34c1f1740c75f45dfb52e6d4d799f7e6682 Mon Sep 17 00:00:00 2001 From: Emile Date: Wed, 9 Oct 2019 12:19:00 +0200 Subject: reading the hostname von env vars --- src/docker.go | 2 +- src/http.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/docker.go b/src/docker.go index 76c90e9..5cc1411 100644 --- a/src/docker.go +++ b/src/docker.go @@ -65,7 +65,7 @@ func spawnCompanion(username string, accesscode string) { Labels: map[string]string{ "traefik.enable": "true", fmt.Sprintf("traefik.http.routers.%s.entrypoints", username): "web", - fmt.Sprintf("traefik.http.routers.%s.rule", username): fmt.Sprintf("Host(`%s.docker.localhost`)", username), + fmt.Sprintf("traefik.http.routers.%s.rule", username): fmt.Sprintf("Host(`%s.%s`)", username, os.Getenv("HOSTNAME")), fmt.Sprintf("traefik.http.services.%s.loadbalancer.server.port", username): "8080", "traefik.docker.network": "circus", }, diff --git a/src/http.go b/src/http.go index 5263062..9632787 100644 --- a/src/http.go +++ b/src/http.go @@ -8,6 +8,7 @@ import ( "io/ioutil" "log" "net/http" + "os" "strings" "github.com/gorilla/mux" @@ -22,6 +23,7 @@ var ( type Credentials struct { Username string Accesscode string + Hostname string } func registerHTTPFlags() { @@ -89,9 +91,6 @@ func registerPostHandler(w http.ResponseWriter, r *http.Request) { r.Form["accesscode"] = []string{accesscodeBase64} credentialsGetHandler(w, r) - //log.Println("redirecting to /credentials") - //endpoint := fmt.Sprintf("/credentials?username=%s&accesscode=%s", usernameBase64, accesscodeBase64) - //http.Redirect(w, r, endpoint, http.StatusSeeOther) } func usernameTakenGetHandler(w http.ResponseWriter, r *http.Request) { @@ -152,6 +151,7 @@ func credentialsGetHandler(w http.ResponseWriter, r *http.Request) { creds := Credentials{ Username: string(username), Accesscode: string(accesscode), + Hostname: string(os.Getenv("HOSTNAME")), } log.Println("executing the template") t.ExecuteTemplate(w, "credentials", creds) -- cgit 1.4.1