diff options
author | Emile <hanemile@protonmail.com> | 2019-10-09 12:19:00 +0200 |
---|---|---|
committer | Emile <hanemile@protonmail.com> | 2019-10-09 12:19:00 +0200 |
commit | fb16e34c1f1740c75f45dfb52e6d4d799f7e6682 (patch) | |
tree | 5a9889e243d6079ec662471e3b95b2cda8dce1d7 /src | |
parent | f331ae701b2dc7f78a14545b49db91e9436c6208 (diff) |
reading the hostname von env vars
Diffstat (limited to 'src')
-rw-r--r-- | src/docker.go | 2 | ||||
-rw-r--r-- | src/http.go | 6 |
2 files changed, 4 insertions, 4 deletions
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) |