From b4f0f461c2d9ea97c640aac4b7a518d35324ddbb Mon Sep 17 00:00:00 2001 From: Zach Wasserman Date: Mon, 22 Mar 2021 15:04:19 -0700 Subject: [PATCH] Make fleetctl preview available over HTTP (#508) Make fleetctl preview available over HTTP Run a second copy of the Fleet server listening over HTTP on localhost:1337 so that the UI can be used without the errors displayed with a self-signed TLS certificate. Osquery clients and fleetctl continue to communicate with the existing Fleet server on https://localhost:8412. Closes #504 Co-authored-by: Mike McNeil --- README.md | 4 +--- cmd/fleetctl/preview.go | 14 +++++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 37ff9d686a..fabcf73d6e 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,7 @@ npm install -g fleetctl sudo fleetctl preview ``` -A local demo copy of the Fleet server is now running at https://localhost:8412. - -> **Seeing a warning in your browser?** You can safely skirt the browser warning ("Your connection is not private") when accessing Fleet locally over https. For example in Google Chrome, visit `chrome://flags/#allow-insecure-localhost` to enable self-signed certs on localhost. Then [refresh Fleet](https://localhost:8412) and click through this warning using the "Advanced" option. +The Fleet UI is now available at http://localhost:1337. #### Your first query Ready to run your first query? Target some of your sample hosts and try it out: diff --git a/cmd/fleetctl/preview.go b/cmd/fleetctl/preview.go index 9b049ff00c..58be05c324 100644 --- a/cmd/fleetctl/preview.go +++ b/cmd/fleetctl/preview.go @@ -67,7 +67,7 @@ Use the stop and reset subcommands to manage the server and dependencies once st } fmt.Println("Pulling Docker dependencies...") - out, err := exec.Command("docker-compose", "pull", "mysql01", "redis01", "fleet01").CombinedOutput() + out, err := exec.Command("docker-compose", "pull").CombinedOutput() if err != nil { fmt.Println(string(out)) return errors.Errorf("Failed to run docker-compose") @@ -85,6 +85,15 @@ Use the stop and reset subcommands to manage the server and dependencies once st return errors.Wrap(err, "wait for server startup") } + // Start fleet02 (UI server) after fleet01 (agent/fleetctl server) + // has finished starting up so that there is no conflict with + // running database migrations. + out, err = exec.Command("docker-compose", "up", "-d", "--remove-orphans", "fleet02").CombinedOutput() + if err != nil { + fmt.Println(string(out)) + return errors.Errorf("Failed to run docker-compose") + } + fmt.Println("Initializing server...") const ( address = "https://localhost:8412" @@ -133,10 +142,9 @@ Use the stop and reset subcommands to manage the server and dependencies once st return errors.Wrap(err, "Error writing fleetctl configuration") } - fmt.Println("Fleet is now available at https://localhost:8412.") + fmt.Println("Fleet UI is now available at http://localhost:1337.") fmt.Println("Username:", username) fmt.Println("Password:", password) - fmt.Println("Note: You can safely ignore the browser warning \"Your connection is not private\". Click through this warning using the \"Advanced\" option. Chrome users may need to configure chrome://flags/#allow-insecure-localhost.") // Create client and get enroll secret client, err := unauthenticatedClientFromCLI(c)