Compare commits

...

6 Commits

Author SHA1 Message Date
Amir Raminfar cfc3e81820 Fixes typo #6 2018-11-20 07:45:24 -08:00
Amir Raminfar 67ab2ab170 1.2.1 2018-11-20 07:13:15 -08:00
Amir Raminfar e1ce378421 Adds SSL support for wss:// (#7)
* 1.2.0

* Adds SSL support
2018-11-20 07:12:13 -08:00
Amir Raminfar f083ea028d Fixes error in readme 2018-11-19 17:25:59 -08:00
Amir Raminfar 063a82198c Updates demo 2018-11-19 17:22:17 -08:00
Amir Raminfar d03c3440de 1.2.0 2018-11-19 13:04:25 -08:00
7 changed files with 41 additions and 30 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ will bind to `localhost` on port `1224`. You can then use use reverse proxy to c
dozzle by default mounts to "/". If you want to control the base path you can use the `--base` option. For example, if you want to mount at "/foobar",
then you can override by using `--base /foobar`.
$ docker run --volume=/var/run/docker.sock:/var/run/docker.sock -p 8888:1224 amir20/dozzle:latest --base /foobar
$ docker run --volume=/var/run/docker.sock:/var/run/docker.sock -p 8888:8080 amir20/dozzle:latest --base /foobar
dozzle will be available at [http://localhost:8080/foobar/](http://localhost:8080/foobar/).
+16 -15
View File
@@ -1,19 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Dozzle</title>
<link href="https://fonts.googleapis.com/css?family=Roboto|Roboto+Mono|Gafata" rel="stylesheet">
<link href="styles.scss" rel="stylesheet">
<script>
window["BASE_PATH"] = "{{ .Base }}";
</script>
<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>
</head>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Dozzle</title>
<link href="https://fonts.googleapis.com/css?family=Roboto|Roboto+Mono|Gafata" rel="stylesheet" />
<link href="styles.scss" rel="stylesheet" />
<script>
window["BASE_PATH"] = "{{ .Base }}";
window["SSL_ENABLED"] = "{{ .SSL }}".toLowerCase() == "true" ? true : false;
</script>
<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>
</head>
<body class="is-dark">
<div id="app"></div>
<script src="main.js"></script>
</body>
<body class="is-dark">
<div id="app"></div>
<script src="main.js"></script>
</body>
</html>
+2 -1
View File
@@ -60,7 +60,8 @@ export default {
ws = null;
this.messages = [];
}
ws = new WebSocket(`ws://${window.location.host}${BASE_PATH}/api/logs?id=${this.id}`);
const protocol = SSL_ENABLED ? "wss" : "ws";
ws = new WebSocket(`${protocol}://${window.location.host}${BASE_PATH}/api/logs?id=${this.id}`);
ws.onopen = e => console.log("Connection opened.");
ws.onclose = e => console.log("Connection closed.");
ws.onerror = e => console.error("Connection error: " + e.data);
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 MiB

After

Width:  |  Height:  |  Size: 24 MiB

+19 -11
View File
@@ -20,8 +20,9 @@ import (
var (
cli *client.Client
addr = flag.String("addr", ":8080", "http service address")
base = flag.String("base", "/", "base address of the application to mount")
addr = ""
ssl = false
base = "/"
upgrader = websocket.Upgrader{}
version = "dev"
commit = "none"
@@ -29,6 +30,10 @@ var (
)
func init() {
flag.StringVar(&addr, "addr", ":8080", "http service address")
flag.StringVar(&base, "base", "/", "base address of the application to mount")
flag.BoolVarP(&ssl, "ssl", "s", false, "Uses websockets over ssl if enabled")
var err error
cli, err = client.NewClientWithOpts(client.FromEnv)
if err != nil {
@@ -40,19 +45,19 @@ func init() {
func main() {
r := mux.NewRouter()
if *base != "/" {
r.HandleFunc(*base, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
http.Redirect(w, req, *base+"/", http.StatusMovedPermanently)
if base != "/" {
r.HandleFunc(base, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
http.Redirect(w, req, base+"/", http.StatusMovedPermanently)
}))
}
s := r.PathPrefix(*base).Subrouter()
s := r.PathPrefix(base).Subrouter()
box := packr.NewBox("./static")
s.HandleFunc("/api/containers.json", listContainers)
s.HandleFunc("/api/logs", logs)
s.HandleFunc("/version", versionHandler)
s.PathPrefix("/").Handler(http.StripPrefix(*base, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
s.PathPrefix("/").Handler(http.StripPrefix(base, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
fileServer := http.FileServer(box)
if box.Has(req.URL.Path) && req.URL.Path != "" && req.URL.Path != "/" {
fileServer.ServeHTTP(w, req)
@@ -61,7 +66,7 @@ func main() {
}
})))
log.Fatal(http.ListenAndServe(*addr, r))
log.Fatal(http.ListenAndServe(addr, r))
}
func versionHandler(w http.ResponseWriter, r *http.Request) {
@@ -87,10 +92,13 @@ func handleIndex(box packr.Box, w http.ResponseWriter) {
}
path := ""
if *base != "/" {
path = *base
if base != "/" {
path = base
}
data := struct{ Base string }{Base: path}
data := struct {
Base string
SSL bool
}{path, ssl}
err = tmpl.Execute(w, data)
if err != nil {
panic(err)
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "dozzle",
"version": "1.1.2",
"version": "1.2.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+2 -1
View File
@@ -1,11 +1,12 @@
{
"name": "dozzle",
"version": "1.1.2",
"version": "1.2.1",
"description": "",
"main": "index.js",
"scripts": {
"start": "concurrently 'go run main.go' 'npm run watch-assets'",
"watch-assets": "parcel watch --public-url '__BASE__' assets/index.html -d static",
"prebuild": "npm run clean",
"build": "parcel build --public-url '__BASE__' assets/index.html -d static",
"clean": "rm -rf static",
"release": "goreleaser --rm-dist"