Compare commits

..
17 Commits
Author SHA1 Message Date
Pierre Dubouilh 698f3ffaf8 bump ui 2019-12-13 00:45:41 +01:00
Pierre Dubouilh dc1011bb5f remove remote state 2019-12-13 00:45:21 +01:00
Pierre Dubouilh 5096f46ba4 ci ping 2019-11-06 19:08:06 +01:00
Pierre Dubouilh f77b10d3de last refactor 2019-11-04 19:28:17 +01:00
Pierre Dubouilh ccd6ae2bea merge master 2019-10-15 19:53:03 +02:00
Pierre Dubouilh 858d30be9b bump ui 2019-10-15 19:40:03 +02:00
Pierre Dubouilh 0b586c5df9 small refactor 2019-10-15 19:39:42 +02:00
Pierre Dubouilh d913176daa tests & bump ui 2019-09-12 21:23:07 +02:00
Pierre Dubouilh beac60f3d8 readme 2019-09-12 21:23:07 +02:00
Pierre Dubouilh da7f60d5fc lock global 2019-09-12 21:23:06 +02:00
Pierre Dubouilh 39d2d4b13f bump ui 2019-09-09 22:09:27 +02:00
Pierre Dubouilh ec7168e718 shift hash setup 2019-09-08 18:13:08 +02:00
Pierre Dubouilh 95f01e47dd bump ui 2019-09-07 11:47:41 +02:00
Pierre Dubouilh c9266d8849 fix hidden files 2019-09-07 11:47:41 +02:00
Pierre Dubouilh e257d1145d hash state 2019-09-07 11:47:41 +02:00
Pierre Dubouilh 698a418e5d maintain state 2019-09-07 11:47:41 +02:00
Pierre Dubouilh e9eb3bf45b test all the extensions 2019-09-04 22:54:20 +02:00
13 changed files with 87 additions and 331 deletions
+3 -3
View File
@@ -7,10 +7,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
- name: Set up Go 1.12
uses: actions/setup-go@v1
with:
go-version: 1.13
go-version: 1.12
id: go
- name: Check out code into the Go module directory
@@ -19,4 +19,4 @@ jobs:
submodules: true
- name: Run
run: make test
run: make ci
+1 -3
View File
@@ -4,8 +4,6 @@ gossa-linux-arm
gossa-linux-arm64
gossa-mac
gossa-windows.exe
gossa_test.go
build-all
.vscode
test-fixture/*
@@ -40,4 +38,4 @@ test-fixture/*/*
!test-fixture/fancy-path
!test-fixture/fancy-path/*
!test-fixture/ext/*
!test-fixture/ext
!test-fixture/ext
+23 -41
View File
@@ -1,65 +1,48 @@
FLAGS := -ldflags "-s -w"
NOCGO := CGO_ENABLED=0
build:
cp src/gossa.go gossa.go
make -C gossa-ui/
go vet && go fmt
${NOCGO} go build ${FLAGS} -o gossa
CGO_ENABLED=0 go build gossa.go
rm gossa.go
install:
sudo cp gossa /usr/local/bin
run:
make build
./gossa -verb=true test-fixture
run-ro:
./gossa -verb=true -ro=true test-fixture
run-extra:
make build
./gossa -verb=true -prefix="/fancy-path/" -k=false -symlinks=true test-fixture
test:
ci:
-@cd test-fixture && ln -s ../support .
make build
rm -rf gossa_test.go
-@cd test-fixture && ln -s ../support .; true
cp src/gossa_test.go .
-@killall gossa; true
-make run &
go test -run TestNormal
killall gossa
-make run-extra &
go test -run TestExtra
killall gossa
-make run-ro &
go test -run TestRo
killall gossa
timeout 15 make run &
sleep 16 && timeout 15 make run-extra &
cp src/gossa_test.go . && go test
rm gossa_test.go
watch:
ls src/* gossa-ui/* | entr -rc make build run
ls src/* gossa-ui/* | entr -rc make run
watch-extra:
ls src/* gossa-ui/* | entr -rc make build run-extra
ls src/* gossa-ui/* | entr -rc make run-extra
watch-ro:
ls src/* gossa-ui/* | entr -rc make build run-ro
watch-test:
ls src/* gossa-ui/* | entr -rc make test
watch-ci:
ls src/* gossa-ui/* | entr -rc make ci
build-all:
cp src/gossa.go gossa.go
make -C gossa-ui/
${NOCGO} GOOS=linux GOARCH=amd64 go build ${FLAGS} -o build-all/gossa-linux64
${NOCGO} GOOS=linux GOARCH=arm go build ${FLAGS} -o build-all/gossa-linux-arm
${NOCGO} GOOS=linux GOARCH=arm64 go build ${FLAGS} -o build-all/gossa-linux-arm64
${NOCGO} GOOS=darwin GOARCH=amd64 go build ${FLAGS} -o build-all/gossa-mac
${NOCGO} GOOS=windows GOARCH=amd64 go build ${FLAGS} -o build-all/gossa-windows.exe
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build gossa.go
mv gossa gossa-linux64
env GOOS=linux GOARCH=arm go build gossa.go
mv gossa gossa-linux-arm
env GOOS=linux GOARCH=arm64 go build gossa.go
mv gossa gossa-linux-arm64
env GOOS=darwin GOARCH=amd64 go build gossa.go
mv gossa gossa-mac
env GOOS=windows GOARCH=amd64 go build gossa.go
mv gossa.exe gossa-windows.exe
rm gossa.go
clean:
@@ -71,4 +54,3 @@ clean:
-rm gossa-linux-arm64
-rm gossa-mac
-rm gossa-windows.exe
-3
View File
@@ -1,3 +0,0 @@
module github.com/pldubouilh/gossa
go 1.16
+11 -16
View File
@@ -1,34 +1,30 @@
gossa
=============
![e](https://user-images.githubusercontent.com/760637/71449335-790a4200-274a-11ea-80be-4c536fbad8a1.gif)
![e](https://user-images.githubusercontent.com/760637/64541706-a3163080-d322-11e9-85ef-a4d8001fa6a5.gif)
[![build status](https://github.com/pldubouilh/gossa/workflows/ci/badge.svg)](https://github.com/pldubouilh/gossa/actions)
[![docker build status](https://img.shields.io/docker/cloud/build/pldubouilh/gossa.svg?logo=docker)](https://hub.docker.com/r/pldubouilh/gossa)
[![docker pulls](https://img.shields.io/docker/pulls/pldubouilh/gossa.svg?logo=docker)](https://hub.docker.com/r/pldubouilh/gossa)
[![github downloads](https://img.shields.io/github/downloads/pldubouilh/gossa/total.svg?logo=github)](https://github.com/pldubouilh/gossa/releases)
a fast and simple webserver for your files, that's dependency-free and with under 250 lines of code, easy to review.
a fast and simple webserver for your files, that's dependency-free and with under 200 lines of code, easy to review.
a [simple UI](https://github.com/pldubouilh/gossa-ui) comes as default, featuring :
* 🔍 files/directories browser & handler
* 📩 drag-and-drop uploader
* 🚀 lightweight and dependency free
* 💾 90s web UI that prints in ms
* 🔍 files/directories browser
* 📩 drag-and-drop file/directory uploader
* 🗺️ files handling - move/rename/delete
* 📸 picture browser
* 📽️ video streaming
* ✍️ simple text editor
* ⌨️ keyboard navigation
* 🥂 fast golang static server
* 🔒 easy/secure multi account setup, read-only mode
* ✨ PWA enabled
* ⌨️ keyboard shortcuts
* 🥂 speed - will easily fill available bandwidth
* 🔒 safe - easy/secure multi account setup
### build
built blobs are available on the [release page](https://github.com/pldubouilh/gossa/releases) - or simply `make build` this repo.
arch linux users can also install through the [user repos](https://aur.archlinux.org/packages/gossa/) - e.g. `yay -S gossa`
### usage
```sh
% ./gossa --help
@@ -36,9 +32,6 @@ arch linux users can also install through the [user repos](https://aur.archlinux
% ./gossa -h 192.168.100.33 ~/storage
```
### shortcuts
press `Ctrl/Cmd + h` to see all the UI/keyboard shortcuts.
### fancier setups
release images are pushed to [dockerhub](https://hub.docker.com/r/pldubouilh/gossa), e.g. :
@@ -47,6 +40,8 @@ release images are pushed to [dockerhub](https://hub.docker.com/r/pldubouilh/gos
% sudo docker run -v ~/LocalDirToShare:/shared -p 8001:8001 pldubouilh/gossa
```
in a do-one-thing-well mindset, HTTPS and authentication has been left to middlewares and proxies. [sample caddy configs](https://github.com/pldubouilh/gossa/blob/master/support/) are available to quickly setup multi users setups along with https.
in a do-one-thing-well mindset, HTTPS and authentication has been left to middlewares and proxies. for instance [caddy](https://caddyserver.com/) handles this very well - have a look at this small [caddy config](https://github.com/pldubouilh/gossa/blob/master/support/Caddyfile) with authentication and option for HTTPS that works along with gossa.
### shortcuts
the default UI is fully usable by through keyboard/UI shortcuts - press `Ctrl/Cmd + h` to see them all.
-18
View File
@@ -1,18 +0,0 @@
name: gossa
version: git
summary: a fast and simple webserver for your files.
description: |
a fast and simple webserver for your files, that's dependency-free and easy to review.
confinement: strict
base: core18
parts:
gossa:
plugin: go
go-importpath: github.com/pldubouilh/gossa
source: .
source-type: git
build-packages:
- gcc
apps:
gossa:
command: gossa
+9 -57
View File
@@ -1,8 +1,6 @@
package main
import (
"archive/zip"
"compress/gzip"
"encoding/json"
"errors"
"flag"
@@ -16,18 +14,17 @@ import (
"net/url"
"os"
"path/filepath"
"sort"
"strconv"
"strings"
)
var host = flag.String("h", "127.0.0.1", "host to listen to")
var port = flag.String("p", "8001", "port to listen to")
var history = flag.Bool("history", true, "keep history for paths visited. default location is path/.gossa_history")
var extraPath = flag.String("prefix", "/", "url prefix at which gossa can be reached, e.g. /gossa/ (slashes of importance)")
var symlinks = flag.Bool("symlinks", false, "follow symlinks \033[4mWARNING\033[0m: symlinks will by nature allow to escape the defined path (default: false)")
var verb = flag.Bool("verb", false, "verbosity")
var skipHidden = flag.Bool("k", true, "\nskip hidden files")
var ro = flag.Bool("ro", false, "read only mode (no upload, rename, move, etc...)")
var initPath = "."
var fs http.Handler
@@ -43,7 +40,6 @@ type rowTemplate struct {
type pageTemplate struct {
Title template.HTML
ExtraPath template.HTML
Ro bool
RowsFiles []rowTemplate
RowsFolders []rowTemplate
}
@@ -84,8 +80,6 @@ func humanize(bytes int64) string {
func replyList(w http.ResponseWriter, r *http.Request, fullPath string, path string) {
_files, err := ioutil.ReadDir(fullPath)
check(err)
sort.Slice(_files, func(i, j int) bool { return strings.ToLower(_files[i].Name()) < strings.ToLower(_files[j].Name()) })
if !strings.HasSuffix(path, "/") {
path += "/"
}
@@ -96,7 +90,6 @@ func replyList(w http.ResponseWriter, r *http.Request, fullPath string, path str
p.RowsFolders = append(p.RowsFolders, rowTemplate{"../", "../", "", "folder"})
}
p.ExtraPath = template.HTML(html.EscapeString(*extraPath))
p.Ro = *ro
p.Title = template.HTML(html.EscapeString(title))
for _, el := range _files {
@@ -112,20 +105,11 @@ func replyList(w http.ResponseWriter, r *http.Request, fullPath string, path str
p.RowsFolders = append(p.RowsFolders, rowTemplate{el.Name() + "/", template.HTML(href), "", "folder"})
} else {
sl := strings.Split(el.Name(), ".")
ext := strings.ToLower(sl[len(sl)-1])
p.RowsFiles = append(p.RowsFiles, rowTemplate{el.Name(), template.HTML(href), humanize(el.Size()), ext})
p.RowsFiles = append(p.RowsFiles, rowTemplate{el.Name(), template.HTML(href), humanize(el.Size()), strings.ToLower(sl[len(sl)-1])})
}
}
if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") {
w.Header().Set("Content-Type", "text/html")
w.Header().Add("Content-Encoding", "gzip")
gz, _ := gzip.NewWriterLevel(w, gzip.BestSpeed) // BestSpeed is much faster than Default on a very unscientific local test, and only ~30% larger (compression remains still very effective, ~6x)
defer gz.Close()
page.Execute(gz, p)
} else {
page.Execute(w, p)
}
page.Execute(w, p)
}
func doContent(w http.ResponseWriter, r *http.Request) {
@@ -157,41 +141,13 @@ func upload(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("ok"))
}
func walkZip(wz *zip.Writer, fp, baseInZip string) {
files, err := ioutil.ReadDir(fp)
check(err)
for _, file := range files {
if !file.IsDir() {
data, err := ioutil.ReadFile(fp + file.Name())
check(err)
f, err := wz.Create(baseInZip + file.Name())
check(err)
_, err = f.Write(data)
check(err)
} else if file.IsDir() {
newBase := fp + file.Name() + "/"
walkZip(wz, newBase, baseInZip+file.Name()+"/")
}
}
}
func zipRPC(w http.ResponseWriter, r *http.Request) {
zipPath := r.URL.Query().Get("zipPath")
zipName := r.URL.Query().Get("zipName")
defer exitPath(w, "zip", zipPath)
wz := zip.NewWriter(w)
w.Header().Add("Content-Disposition", "attachment; filename=\""+zipName+".zip\"")
walkZip(wz, checkPath(zipPath)+"/", "")
wz.Close()
}
func rpc(w http.ResponseWriter, r *http.Request) {
var err error
var rpc rpcCall
defer exitPath(w, "rpc", rpc)
bodyBytes, _ := ioutil.ReadAll(r.Body)
json.Unmarshal(bodyBytes, &rpc)
defer exitPath(w, "rpc", rpc)
ret := "ok"
if rpc.Call == "mkdirp" {
err = os.MkdirAll(checkPath(rpc.Args[0]), os.ModePerm)
@@ -202,7 +158,7 @@ func rpc(w http.ResponseWriter, r *http.Request) {
}
check(err)
w.Write([]byte("ok"))
w.Write([]byte(ret))
}
func checkPath(p string) string {
@@ -232,15 +188,11 @@ func main() {
initPath, err = filepath.Abs(initPath)
check(err)
if !*ro {
http.HandleFunc(*extraPath+"rpc", rpc)
http.HandleFunc(*extraPath+"post", upload)
}
http.HandleFunc(*extraPath+"zip", zipRPC)
http.HandleFunc(*extraPath+"rpc", rpc)
http.HandleFunc(*extraPath+"post", upload)
http.HandleFunc("/", doContent)
fs = http.StripPrefix(*extraPath, http.FileServer(http.Dir(initPath)))
fmt.Printf("Gossa starting on directory %s\nListening on http://%s:%s%s\n", initPath, *host, *port, *extraPath)
fmt.Printf("Gossa startig on directory %s\nListening on http://%s:%s%s\n", initPath, *host, *port, *extraPath)
err = http.ListenAndServe(*host+":"+*port, nil)
check(err)
}
+14 -97
View File
@@ -2,13 +2,13 @@ package main
import (
"bytes"
"crypto/sha256"
"fmt"
"io/ioutil"
"net/http"
"regexp"
"strings"
"testing"
"time"
)
func dieMaybe(t *testing.T, err error) {
@@ -22,16 +22,11 @@ func trimSpaces(str string) string {
return space.ReplaceAllString(str, " ")
}
func getRaw(t *testing.T, url string) []byte {
func get(t *testing.T, url string) string {
resp, err := http.Get(url)
dieMaybe(t, err)
body, err := ioutil.ReadAll(resp.Body)
dieMaybe(t, err)
return body
}
func get(t *testing.T, url string) string {
body := getRaw(t, url)
return trimSpaces(string(body))
}
@@ -89,7 +84,7 @@ func fetchAndTestDefault(t *testing.T, url string) string {
return body0
}
func doTestRegular(t *testing.T, url string, testExtra bool) {
func doTest(t *testing.T, url string, testExtra bool) {
var payload, path, body0, body1, body2 string
// ~~~~~~~~~~~~~~~~~
@@ -118,21 +113,6 @@ func doTestRegular(t *testing.T, url string, testExtra bool) {
fetchAndTestDefault(t, url+path) // extra path will just redirect to root dir
}
// ~~~~~~~~~~~~~~~~~
fmt.Println("\r\n~~~~~~~~~~ test zip")
bodyRaw := getRaw(t, url+"zip?zipPath=%2F%E4%B8%AD%E6%96%87%2F&zipName=%E4%B8%AD%E6%96%87")
hashStr := fmt.Sprintf("%x", sha256.Sum256(bodyRaw))
if hashStr != "b02436a76b149e6c4458bbbe622ab7c5e789bb0d26b87f604cf0f989cfaf669f" {
t.Fatal("invalid zip checksum", hashStr)
}
// ~~~~~~~~~~~~~~~~~
fmt.Println("\r\n~~~~~~~~~~ test zip invalid path")
body0 = get(t, url+"zip?zipPath=%2Ftmp&zipName=subdir")
if body0 != `error` {
t.Fatal("zip passed for invalid path")
}
// ~~~~~~~~~~~~~~~~~
fmt.Println("\r\n~~~~~~~~~~ test mkdir rpc")
body0 = postJSON(t, url+"rpc", `{"call":"mkdirp","args":["/AAA"]}`)
@@ -249,83 +229,20 @@ func doTestRegular(t *testing.T, url string, testExtra bool) {
if body0 != `ok` {
t.Fatal("cleanup errored #2")
}
fmt.Printf("\r\n=========\r\n")
}
func doTestReadonly(t *testing.T, url string) {
var payload, path, body0, body1 string
// ~~~~~~~~~~~~~~~~~
fmt.Println("\r\n~~~~~~~~~~ test fetching default path")
fetchAndTestDefault(t, url)
// ~~~~~~~~~~~~~~~~~
fmt.Println("\r\n~~~~~~~~~~ test fetching an invalid path - redirected to root")
fetchAndTestDefault(t, url+"../../")
fetchAndTestDefault(t, url+"hols/../../")
// ~~~~~~~~~~~~~~~~~
fmt.Println("\r\n~~~~~~~~~~ test fetching regular files")
body0 = get(t, url+"subdir_with%20space/file_with%20space.html")
body1 = get(t, url+"fancy-path/a")
if body0 != `<b>spacious!!</b> ` || body1 != `fancy! ` {
t.Fatal("fetching a regular file errored")
}
// ~~~~~~~~~~~~~~~~~
fmt.Println("\r\n~~~~~~~~~~ test fetching a invalid file")
path = "../../../../../../../../../../etc/passwd"
if get(t, url+path) != `error` {
t.Fatal("fetching a invalid file didnt errored")
}
// ~~~~~~~~~~~~~~~~~
fmt.Println("\r\n~~~~~~~~~~ test mkdir rpc")
body0 = postJSON(t, url+"rpc", `{"call":"mkdirp","args":["/AAA"]}`)
if body0 == `ok` {
t.Fatal("mkdir rpc passed - should not be allowed")
}
// ~~~~~~~~~~~~~~~~~
fmt.Println("\r\n~~~~~~~~~~ test post file")
path = "%2F%E1%84%92%E1%85%A1%20%E1%84%92%E1%85%A1" // "하 하" encoded
payload = "123 하"
body0 = postDummyFile(t, url, path, payload)
body1 = get(t, url+path)
if body0 == `ok` {
t.Fatal("post file passed - should not be allowed")
}
// ~~~~~~~~~~~~~~~~~
fmt.Println("\r\n~~~~~~~~~~ test mv rpc")
body0 = postJSON(t, url+"rpc", `{"call":"mv","args":["/AAA", "/hols/AAA"]}`)
body1 = fetchAndTestDefault(t, url)
if body0 == `ok` {
t.Fatal("mv rpc passed - should not be allowed")
}
// ~~~~~~~~~~~~~~~~~
fmt.Println("\r\n~~~~~~~~~~ test rm rpc & cleanup")
body0 = postJSON(t, url+"rpc", `{"call":"rm","args":["/hols/AAA"]}`)
if body0 == `ok` {
t.Fatal("cleanup passed - should not be allowed")
}
fmt.Printf("\r\n=========\r\n")
}
func TestNormal(t *testing.T) {
func TestGetFolder(t *testing.T) {
time.Sleep(6 * time.Second)
fmt.Println("========== testing normal path ============")
doTestRegular(t, "http://127.0.0.1:8001/", false)
}
url := "http://127.0.0.1:8001/"
doTest(t, url, false)
func TestExtra(t *testing.T) {
fmt.Println("========== testing extras options ============")
doTestRegular(t, "http://127.0.0.1:8001/fancy-path/", true)
}
fmt.Printf("\r\n=========\r\n")
time.Sleep(10 * time.Second)
func TestRo(t *testing.T) {
fmt.Println("========== testing read only ============")
doTestReadonly(t, "http://127.0.0.1:8001/")
url = "http://127.0.0.1:8001/fancy-path/"
fmt.Println("========== testing at fancy path ============")
doTest(t, url, true)
fmt.Printf("\r\n=========\r\n")
}
+8
View File
@@ -0,0 +1,8 @@
# Caddy config
# to enable https just set a valid domain (e.g. mydomain.com) instead of :8080 - how simple !
# authentication has been setup with 2 users, alice and bob
:8080
basicauth / alice paul
basicauth / bob dylan
proxy / 127.0.0.1:8001
+2 -2
View File
@@ -3,9 +3,9 @@ COPY . /gossaSrc
RUN cd /gossaSrc && make
FROM alpine
ENV UID="1000" GID="1000" HOST="0.0.0.0" PORT="8001" PREFIX="/" FOLLOW_SYMLINKS="false" SKIP_HIDDEN_FILES="true" DATADIR="/shared" READONLY="false"
ENV UID="1000" GID="1000" HOST="0.0.0.0" PORT="8001" PREFIX="/" FOLLOW_SYMLINKS="false" SKIP_HIDDEN_FILES="true" DATADIR="/shared"
EXPOSE 8001
RUN apk add --no-cache su-exec
COPY --from=builder /gossaSrc/gossa /gossa
RUN echo -e 'exec su-exec ${UID}:${GID} /gossa -h ${HOST} -p ${PORT} -k=${SKIP_HIDDEN_FILES} -ro=${READONLY} --symlinks=${FOLLOW_SYMLINKS} --prefix=${PREFIX} ${DATADIR}'>> /start.sh
RUN echo -e 'exec su-exec ${UID}:${GID} /gossa -h ${HOST} -p ${PORT} -k=${SKIP_HIDDEN_FILES} --symlinks=${FOLLOW_SYMLINKS} --prefix=${PREFIX} ${DATADIR}'>> /start.sh
ENTRYPOINT [ "sh", "/start.sh" ]
+8
View File
@@ -0,0 +1,8 @@
FROM pldubouilh/gossa
RUN apk update && apk add curl ca-certificates caddy
ENV UID="1000" GID="1000" HOST="127.0.0.1" PORT="8001" PREFIX="/" FOLLOW_SYMLINKS="false" SKIP_HIDDEN_FILES="true" DATADIR="/shared"
EXPOSE 443
RUN echo -e 'exec su-exec ${UID}:${GID} /gossa -h ${HOST} -p ${PORT} -k=${SKIP_HIDDEN_FILES} --symlinks=${FOLLOW_SYMLINKS} --prefix=${PREFIX} ${DATADIR} & \n caddy' > /start.sh
ENTRYPOINT [ "sh", "/start.sh" ]
+7 -90
View File
@@ -1,110 +1,27 @@
## docker
the master branch is automatically built and pushed to [dockerhub](https://hub.docker.com/r/pldubouilh/gossa) under `pldubouilh/gossa`.
```sh
# pull from dockerhub and run
% mkdir ~/LocalDirToShare
% sudo docker run -v ~/LocalDirToShare:/shared -p 8001:8001 pldubouilh/gossa
# options are settable through env. variabes. all the options are the build.Dockerfile
% sudo docker run -e PREFIX="/gossa/" -v ~/LocalDirToShare:/shared -p 8001:8001 pldubouilh/gossa
```
if you prefer building the image yourself :
```sh
# build gossa within a build container, needs to be ran within the sources, ../ from here, and run
% mkdir ~/LocalDirToShare
% docker build -t gossa -f support/build.Dockerfile .
% sudo docker run -v ~/LocalDirToShare:/shared -p 8001:8001 gossa
```
a docker-compose example image is also provided. running docker compose should be straightforward : `docker-compose up .` have a look in `docker-compose.yml` for further configuration.
the options are settable through environment variables that can be passed starting off the docker image.
## multi-account setup
authentication / user routing has been left out of the design of gossa, as simple tools are already available for this purpose. [caddy](https://caddyserver.com/v1/) is used here as an example, but other proxy can be used in a similar fashion.
### example 1 root, multiple read-only users
this sample caddy config will
+ enable https on the domain myserver.com
+ password protect the access
+ route the root user requests to 1 gossa instance
+ route user1 and user2 requests to a readonly gossa instance
a fancy docker image using [Caddy](https://caddyserver.com/) is also provided. have a look at the simple config file `Caddyfile`, it shows how to use http basic authentication, and automatic TLS for hands-free https 🎉
```sh
myserver.com
# proxy regular and read only instance
proxy / 127.0.0.1:8001
proxy /ro 127.0.0.1:8002 { without /ro }
# reroute non-root user to read-only
# cm9... is the output of `printf "root:password" | base64`
rewrite {
if {>Authorization} not "Basic cm9vdDpwYXNzd29yZA=="
to /ro/{path}
}
# gate access
basicauth / root password
basicauth / ro_user1 passworduser1
basicauth / ro_user2 passworduser2
# checkout the caddy config, build, and run docker image
% vim caddy.Dockerfile
% docker build -t gossa-caddy -f caddy.Dockerfile .
% sudo docker run -v ~/LocalDirToShare:/shared -v `pwd`/Caddyfile:/Caddyfile --net=host gossa-caddy
```
then simply start the 2 gossa instances, and caddy
```sh
# start an instance in readonly
% ./gossa -ro=true -p 8002 ~/folder &
# start an instance with access to hidden files
% ./gossa -k=false -p 8001 ~/folder &
# start caddy
% ./caddy
```
### example 2 users on 2 different folders
this sample caddy config will
+ enable https on the domain myserver.com
+ password protect the access
+ route user1 to own folder
+ route user2 to own folder
+ share a folder between 2 users with a symlink
```sh
myserver.com
proxy /user1 127.0.0.1:8001 { without /user1 }
proxy /user2 127.0.0.1:8002 { without /user2 }
basicauth / user1 passworduser1
basicauth / user2 passworduser2
rewrite {
if {>Authorization} is "Basic dXNlcjE6cGFzc3dvcmR1c2VyMQ=="
to /user1/{path}
}
rewrite {
if {>Authorization} is "Basic dXNlcjI6cGFzc3dvcmR1c2VyMg=="
to /user2/{path}
}
```
start 2 gossa instances, and caddy
```sh
# create symlink to share folder between 2 users
% ln -s /path/shared test/user1
% ln -s /path/shared test/user2
# start gossa & caddy
% ./gossa -p 8001 -symlinks=true test/user1 &
% ./gossa -p 8002 -symlinks=true test/user2 &
% ./caddy
```
a docker-compose example image is also provided. running docker compose should be straightforward : `docker-compose up .` have a look in `docker-compose.yml` for further configuration.