• Stars
    star
    119
  • Rank 296,204 (Top 6 %)
  • Language
    Go
  • License
    GNU General Publi...
  • Created about 4 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a lightweight, easy-to-use WebDAV server

GoWebdav

Share local files with WebDAV, lightweight and very easy to use.

中文

feature

  • Based on Golang implementation, high performance

  • Finally compiled into a single binary file, no need for Apache and other environments, more stable

  • Support browser access

  • Multiple WebDAV services can be enabled under the same port, each with a different mount directory, user name, and password

  • Docker is well supported

quickstart

bin

Go to https://github.com/117503445/GoWebDAV/releases to download the latest binaries.

Then run . /gowebdav

GoWebDAV will automatically create the example file under the ./data path with the following file structure

> tree ./data
./data
├── public-writable
│ └── 1.txt
├── public-readonly
│ └── 2.txt
└── private-writable
    └── 3.txt

Visit http://localhost:80 with your browser and you will see 3 different GoWebDAV services.

index

where http://localhost:80/public-writable is the public-writable service that maps the local ./data/public-writable folder. It is Anonymizable and writable. You can view the contents of the file in the browser, as well as perform operations such as uploading and deleting.

public-writable

http://localhost:80/public-readonly is the public-readonly service that maps the local ./data/public-readonly folder. It is Anonymizable and read-only. You can view the contents of the file in your browser, but you cannot upload, delete, etc.

public-readonly

http://localhost:80/private-writable is the private-writable service that maps the local ./data/private-writable folder. It is user-authenticated and writable. After logging in with user1 and pass1, you can view the contents of the files in the browser, as well as upload, delete, etc.

private-writable

The dav parameter can also be specified to configure the local path, user authentication, read-only, etc. properties of the WebDAV service, as described in the Configuration Strings Description section. When dav is not specified, the default dav parameter used by GoWebDAV is /public-writable,./data/public-writable,null,null,false;/public-readonly,./data/public-readonly,null,null,true;/private-writable,./data/private-writable,user1,pass1,false.

Docker

The local file paths to be shared are /root/dir1 and /root/dir2.

docker run -it --name go_webdav -d -v /root/dir1:/root/dir1 -v /root/dir2:/root/dir2 -e dav="/dav1,/root/dir1,user1,pass1,true;/dav2,/root/dir2,null,null,false" -p 80:80 --restart=unless-stopped 117503445/go_webdav
-e dav="/dav1,/root/dir1,user1,pass1,true;/dav2,/root/dir2,null,null,false"

Indicates passing a configuration string into the Docker image.

Then open http://localhost/dav1 and http://localhost/dav2 in the browser or webdav client like raidrive.

Configuration String

You can pass the --dav parameter to change the configuration.

On Windows, the same call as quickstart is made as follows

// cmd
gowebdav_windows_amd64.exe --dav "/public-writable,./data/public-writable,null,null,false;/public-readonly,./data/public-readonly,null,null,true;/private-writable,./data/private-writable,user1,pass1,false"

// PowerShell
.\gowebdav_windows_amd64.exe --dav "/public-writable,./data/public-writable,null,null,false;/public-readonly,./data/public-readonly,null,null,true;/private-writable,./data/private-writable,user1,pass1,false"

On Windows, the same call as quickstart is made as follows

./gowebdav_linux_amd64 --dav "/public-writable,./data/public-writable,null,null,false;/public-readonly,./data/public-readonly,null,null,true;/private-writable,./data/private-writable,user1,pass1,false"

The following is a specific explanation of dav

Use a semicolon to separate each WebDAV service configuration, which means that "/dav1,/root/dir1,user1,pass1,true;/dav2,/root/dir2,null,null,false" describes 2 services, which are

/dav1,/root/dir1,user1,pass1,false

and

/dav2,/root/dir2,null,null,true

The first service will mount the /root/dir1 directory of the Docker image under /dav1. The required username and password for access are user1 and pass1 respectively.

Then, according to the previous -v /root/dir1:/root/dir1, the mapping relationship with /root/dir1 of the physical machine can be completed and accessed.

The fifth parameter false indicates that this is a non-read-only service that supports addition, deletion, modification and query.

The second service will mount the /root/dir2 directory of the Docker image under /dav2. The user name and password required for access are null and null respectively. At this time, it means that the service can be accessed without a password. .

Then according to the previous -v /root/dir2:/root/dir2, you can complete the mapping relationship with /root/dir2 of the physical machine and access it.

The fifth parameter true indicates that this is a read-only service, only supports GET, does not support additions, deletions and modifications.

This method is recommended for file sharing without confidentiality requirements.

You can pass in the --port parameter to change the port to listen on. The default listens on port 80.

# Listening on port 8080
./gowebdav_linux_amd64 --port 8080

Docker Compose

Expose /root/dir1, which requires authentication, and /root/dir2, which does not require authentication.

version: "3.9"
services:
  go_webdav:
    volumes:
      - "/root/dir1:/root/dir1"
      - "/root/dir2:/root/dir2"
    environment:
      - "dav=/dav1,/root/dir1,user1,pass1,true;/dav2,/root/dir2,null,null,false"
    ports:
      - "80:80"
    restart: unless-stopped
    image: 117503445/go_webdav

Background introduction

GoWebdav is used to build a WebDAV-based file sharing server.

Reasons to use WebDAV

  1. Samba is inconvenient to use on Windows clients, and it is difficult to use non-default ports.

  2. FTP mount trouble.

  3. NextCloud is too heavy and difficult to share files on the server.

Because I didn't see a server-side implementation that could meet the above features, this project recreated a WebDAV Server.

Local debugging

Rename config.yml.example to config.yml, configure in config.yml file

go run .

Local Docker build

Using a layered build, the executable app is built through go build in the build layer, and then run in the prod layer. If you need to modify the structure of the configuration file later, you will also need to modify the Dockerfile.

docker build -t 117503445/go_webdav .
docker run --name go_webdav -d -v ${PWD}/TestDir1:/root/TestDir1 -v ${PWD}/TestDir2:/root/TestDir2 -e dav="/dav1,/root/TestDir1,user1,pass1,false;/dav2,/root/TestDir2,user2,pass2,true" -p 80:80 --restart=unless-stopped 117503445/go_webdav

Safety

HTTP Basic Auth is used for authentication, and the account password is sent in clear text, which has no security at all. If important files or passwords are involved, be sure to use a gateway such as Nginx or Traefik to provide HTTPS.

Acknowledgments

https://github.com/dom111/webdav-js provides front-end support

More Repositories

1

yunzai-bot-web

基于 Web 的 Yunzai-Bot 发行版,不依赖 QQ,极易部署!
JavaScript
91
star
2

flow-pdf

A PDF to HTML converter with silky smooth reading experience
Python
52
star
3

qq_get_message

2020年从安卓QQ数据库提取聊天记录
Python
45
star
4

database_homework

XDU 数据库 实验 学生成绩管理系统 后端
Java
14
star
5

Paster

模拟键盘输入以规避禁止粘贴
C#
10
star
6

colab_ssh_frp

基于 frp 使用 colab 的 ssh
Shell
10
star
7

bilibili_auto_download

自动下载 bilibili 视频
Python
7
star
8

push

Java
6
star
9

syncthing-code

Sync code across multiple devices, based on Syncthing
Rust
6
star
10

AJJCut

C#
5
star
11

elasticsearch-deploy

deploy elasticsearch, kibana ... by docker
Dockerfile
5
star
12

wiki

117503445's wiki
5
star
13

pptx-speech

Python
4
star
14

XDOJ

AC code in XDOJ
C
4
star
15

uni-drop

TypeScript
3
star
16

xdu_electricity_balance

XDU 电费查询
Python
2
star
17

WechatSport-Auto.Js

微信运动数据爬取的 安卓端 数据爬取脚本,基于AutoJs Pro
JavaScript
2
star
18

typora-mono-theme

使用 Microsoft YaHei Mono 的 typora 主题
CSS
2
star
19

docker-dev

use docker to build development environment
Shell
2
star
20

get_163mooc_answer

get the answer of mooc
HTML
2
star
21

elevator_dispatch

工程概论上大作业,电梯调度
Python
2
star
22

synctainer

download container in gcr.io(etc.), upload to ACR
Go
2
star
23

starrail-relic

星穹铁道遗器批量锁定/解锁
Go
2
star
24

TimeMix

Mi Mix似的美丽
C#
1
star
25

go_back_n

计网大作业,回退 N 帧模拟,基于WPF
C#
1
star
26

experiment-helper-core

实验助手 核心逻辑解析
JavaScript
1
star
27

experiment-helper-mobile

Vue
1
star
28

UWPProxy

让 UWP 添加使用代理的能力
C#
1
star
29

XdFood

2019.4.20 黑客马拉松 西电吃货
C#
1
star
30

Wizz-Home-Page

Wizz's Home Page
Go
1
star
31

LocalOJ

Auto test program
C#
1
star
32

CommentPPT

Comment PPT in a more elegant way.
C#
1
star
33

goframe_template

学习 goframe
Go
1
star
34

s3-database

JavaScript SDK uses S3 as the database and does not require a backend.
TypeScript
1
star
35

latex-arch

LaTeX Docker image based on Arch Linux
Shell
1
star
36

vsc-server-setup

Automatically install the latest version of VSCode Server
Python
1
star
37

history-ppt

2019大一下近代史ppt
1
star
38

CheckIn

用于长河高级中学的点名程序
C#
1
star
39

aplmu_backend

Aplmu By Spring Boot
Java
1
star
40

spring_boot_docker

Spring Boot 的 Docker 化实践
Java
1
star
41

data_struct_oj

西电 数据结构 OJ 上机题
C++
1
star
42

oj

Automatically compile and test command line programs on the fly.
Go
1
star
43

tasksflow

Handling Complex Workflows with Tasks
Python
1
star
44

share_board_frontend

基于 Websocket 的 同步 Web 手写板
Vue
1
star
45

rock-mempool

交易池
Go
1
star