diff --git a/cmd/dashboard.go b/cmd/dashboard.go index 7ba5415..6d46d61 100644 --- a/cmd/dashboard.go +++ b/cmd/dashboard.go @@ -11,6 +11,7 @@ import ( // RunDashboard runs the dashboard with the supplied flags func RunDashboard() { dashboardVersion := flag.Bool("version", false, "Prints the dashboard version") + address := flag.String("address", "localhost", "Address to listen on. Only accepts IP address or localhost as a value") port := flag.Int("port", 8080, "Port to listen to") flag.Parse() @@ -19,6 +20,6 @@ func RunDashboard() { fmt.Println(version.GetVersion()) os.Exit(0) } else { - RunWebServer(*port) + RunWebServer(*address, *port) } } diff --git a/cmd/webserver.go b/cmd/webserver.go index b9012c3..4836cd3 100644 --- a/cmd/webserver.go +++ b/cmd/webserver.go @@ -56,7 +56,7 @@ var comps components.Components var configs configurations.Configurations // RunWebServer starts the web server that serves the Dapr UI dashboard and the API -func RunWebServer(port int) { +func RunWebServer(address string, port int) { platform := "" kubeClient, daprClient, _ := kube.Clients() if kubeClient != nil { @@ -94,11 +94,11 @@ func RunWebServer(port int) { srv := &http.Server{ Handler: r, - Addr: fmt.Sprintf("0.0.0.0:%v", port), + Addr: fmt.Sprintf("%v:%v", address, port), WriteTimeout: 15 * time.Second, ReadTimeout: 15 * time.Second, } - fmt.Printf("Dapr Dashboard running on http://localhost:%v\n", port) + fmt.Printf("Dapr Dashboard running on http://%v:%v\n", address, port) log.Fatal(srv.ListenAndServe()) }