• Stars
    star
    2,441
  • Rank 18,704 (Top 0.4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 8 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

The best HTTP Static File Server, write with golang+vue

gohttpserver

Build Status Docker Automated build

  • Goal: Make the best HTTP File Server.
  • Features: Human-friendly UI, file uploading support, direct QR-code generation for Apple & Android install package.

Demo site

  • 目标: 做最好的HTTP文件服务器
  • 功能: 人性化的UI体验,文件的上传支持,安卓和苹果安装包的二维码直接生成。

Binaries can be downloaded from this repo releases

Requirements

Tested with go-1.16

Screenshots

screen

Features

  1. Support QRCode code generate
  2. Breadcrumb path quick change
  3. All assets package to Standalone binary
  4. Different file type different icon
  5. Support show or hide hidden files
  6. Upload support (auth by token or session)
  7. README.md preview
  8. HTTP Basic Auth
  9. Partial reload pages when directory change
  10. When only one dir under dir, path will combine two together
  11. Directory zip download
  12. Apple ipa auto generate .plist file, qrcode can be recognized by iphone (Require https)
  13. Plist proxy
  14. Download count statistics
  15. CORS enabled
  16. Offline download
  17. Code file preview
  18. Edit file support
  19. Global file search
  20. Hidden work download and qrcode in small screen
  21. Theme select support
  22. OK to working behide Nginx
  23. .ghs.yml support (like .htaccess)
  24. Calculate md5sum and sha
  25. Folder upload
  26. Support sort by size or modified time
  27. Add version info into index page
  28. Add api /-/info/some.(apk|ipa) to get detail info
  29. Add api /-/apk/info/some.apk to get android package info
  30. Auto tag version
  31. Custom title support
  32. Support setting from conf file
  33. Quick copy download link
  34. Show folder size
  35. Create folder
  36. Skip delete confirm when alt pressed
  37. Support unzip zip file when upload(with form: unzip=true)

Installation

$ go install github.com/codeskyblue/gohttpserver@latest

Or download binaries from github releases

If you are using Mac, simply run command

$ brew install codeskyblue/tap/gohttpserver

Usage

Listen on port 8000 of all interfaces, and enable file uploading.

$ gohttpserver -r ./ --port 8000 --upload

Use command gohttpserver --help to see more usage.

Docker Usage

share current directory

$ docker run -it --rm -p 8000:8000 -v $PWD:/app/public --name gohttpserver codeskyblue/gohttpserver

Share current directory with http basic auth

$ docker run -it --rm -p 8000:8000 -v $PWD:/app/public --name gohttpserver \
  codeskyblue/gohttpserver \
  --auth-type http --auth-http username:password

Share current directory with openid auth. (Works only in netease company.)

$ docker run -it --rm -p 8000:8000 -v $PWD:/app/public --name gohttpserver \
  codeskyblue/gohttpserver \
  --auth-type openid

To build image yourself, please change the PWD to the root of this repo.

$ cd gohttpserver/
$ docker build -t codeskyblue/gohttpserver -f docker/Dockerfile .

Authentication options

  • Enable basic http authentication

    $ gohttpserver --auth-type http --auth-http username:password
  • Use openid auth

    $ gohttpserver --auth-type openid --auth-openid https://login.example-hostname.com/openid/
  • Use oauth2-proxy with

    $ gohttpserver --auth-type oauth2-proxy

    You can configure to let a http reverse proxy handling authentication. When using oauth2-proxy, the backend will use identification info from request headers X-Auth-Request-Email as userId and X-Auth-Request-Fullname as user's display name. Please config your oauth2 reverse proxy yourself. More about oauth2-proxy.

    All required headers list as following.

    header value
    X-Auth-Request-Email userId
    X-Auth-Request-Fullname user's display name(urlencoded)
    X-Auth-Request-User user's nickname (mostly email prefix)
  • Enable upload

    $ gohttpserver --upload
  • Enable delete and Create folder

    $ gohttpserver --delete

Advanced usage

Add access rule by creating a .ghs.yml file under a sub-directory. An example:

---
upload: false
delete: false
users:
- email: "[email protected]"
  delete: true
  upload: true
  token: 4567gf8asydhf293r23r

In this case, if openid auth is enabled and user "[email protected]" has logged in, he/she can delete/upload files under the directory where the .ghs.yml file exits.

token is used for upload. see upload with curl

For example, in the following directory hierarchy, users can delete/uploade files in directory foo, but he/she cannot do this in directory bar.

root -
  |-- foo
  |    |-- .ghs.yml
  |    `-- world.txt 
  `-- bar
       `-- hello.txt

User can specify config file name with --conf, see example config.yml.

To specify which files is hidden and which file is visible, add the following lines to .ghs.yml

accessTables:
- regex: block.file
  allow: false
- regex: visual.file
  allow: true

ipa plist proxy

This is used for server on which https is enabled. default use https://plistproxy.herokuapp.com/plist

$ gohttpserver --plistproxy=https://someproxyhost.com/

Test if proxy works:

$ http POST https://someproxyhost.com/plist < app.plist
{
	"key": "18f99211"
}
$ http GET https://someproxyhost.com/plist/18f99211
# show the app.plist content

If your ghs running behide nginx server and have https configed. plistproxy will be disabled automaticly.

Upload with CURL

For example, upload a file named foo.txt to directory somedir

$ curl -F [email protected] localhost:8000/somedir
{"destination":"somedir/foo.txt","success":true}
# upload with token
$ curl -F [email protected] -F token=12312jlkjafs localhost:8000/somedir
{"destination":"somedir/foo.txt","success":true}

# upload and change filename
$ curl -F [email protected] -F filename=hi.txt localhost:8000/somedir
{"destination":"somedir/hi.txt","success":true}

Upload zip file and unzip it (zip file will be delete when finished unzip)

$ curl -F [email protected] -F unzip=true localhost:8000/somedir
{"success": true}

Note: \/:*<>| are not allowed in filenames.

Deploy with nginx

Recommended configuration, assume your gohttpserver listening on 127.0.0.1:8200

server {
  listen 80;
  server_name your-domain-name.com;

  location / {
    proxy_pass http://127.0.0.1:8200; # here need to change
    proxy_redirect off;
    proxy_set_header  Host    $host;
    proxy_set_header  X-Real-IP $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header  X-Forwarded-Proto $scheme;

    client_max_body_size 0; # disable upload limit
  }
}

gohttpserver should started with --xheaders argument when behide nginx.

Refs: http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size

gohttpserver also support --prefix flag which will help to when meet / is occupied by other service. relative issue #105

Usage example:

# for gohttpserver
$ gohttpserver --prefix /foo --addr :8200 --xheaders

Nginx settigns

server {
  listen 80;
  server_name your-domain-name.com;

  location /foo {
    proxy_pass http://127.0.0.1:8200; # here need to change
    proxy_redirect off;
    proxy_set_header  Host    $host;
    proxy_set_header  X-Real-IP $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header  X-Forwarded-Proto $scheme;

    client_max_body_size 0; # disable upload limit
  }
}

FAQ

How the query is formated

The search query follows common format rules just like Google. Keywords are seperated with space(s), keywords with prefix - will be excluded in search results.

  1. hello world means must contains hello and world
  2. hello -world means must contains hello but not contains world

Developer Guide

Depdencies are managed by govendor

  1. Build develop version. assets directory must exists
$ go build
$ ./gohttpserver
  1. Build single binary release
$ go build

Theme are defined in assets/themes directory. Now only two themes are available, "black" and "green".

Reference Web sites

Go Libraries

History

The old version is hosted at https://github.com/codeskyblue/gohttp

LICENSE

This project is licensed under MIT.

More Repositories

1

go-sh

like python-sh, for easy call shell with golang.
Go
1,072
star
2

gosuv

Deprecated!!! Process managerment writtern by golang, inspired by python-supervisor
JavaScript
643
star
3

fswatch

Watch file change, and trigger commands. (Cross platform)
Go
342
star
4

gohttp

HTTP file server written by golang + reactjs, not maintained, move to https://github.com/codeskyblue/gohttpserver
JavaScript
240
star
5

gobuild

not maintained, moved to https://github.com/gobuild/gobuild
Go
200
star
6

webcron

A new crontab that have a web page in order to replace the original crontab. Now it can try on test.
Go
161
star
7

tidevice3

wrapper for pymobiledevice3 to make it more easy to use.
Python
129
star
8

uiautodev

Mobile UI viewer in browser, view the UI in a tree view, and generate XPath automatically.
Python
55
star
9

go-reactjs-example

This is an exmple web use Golang And ReactJS
Go
54
star
10

docker-gogs

docker file for gogits
Shell
49
star
11

fa

FA(fast adb) helps you win at ADB(Android Debug Bridge).
Go
48
star
12

audiowire

Transfer PC Audio(Sound) to Browser (Beta)
JavaScript
37
star
13

heartbeat

heart beat for process status check. (心跳检测,UDP协议)
Go
23
star
14

kexec

Killable os/exec for golang library.
Go
21
star
15

kproc

go lib. offer a better way to kill all child process. [cross platform]
Go
21
star
16

proxylocal

Proxy local server to public network. (include server and client)
Go
15
star
17

netcat

example program, only for study golang.
Go
15
star
18

dockerignore

go library parse gitignore file, source code most from docker
Go
13
star
19

airfps

For mobile phone game to get FPS: frame per second.
C
10
star
20

dingrobot

DingTake Robot API
Go
9
star
21

node-python-rpc

Node modules which helps call python code in node
Python
9
star
22

apkinfo

get apkinfo use pure go code. (packageName, mainActivty etc...)
Go
8
star
23

go-image-encode-benchmark

Golang Image encode bench mark
Go
7
star
24

sshg

ssh client with quick search and remote config
Python
6
star
25

GoHello

Sample Android Project With Golang1.4 (AndroidStudioIDE)
Java
6
star
26

beelog

A simple log for Debug Trace Warn Error Critacal, extract code from astaxie/beego.
Go
6
star
27

adb

adb for docker armhf
Dockerfile
5
star
28

klog

Simple log extention for golang official log, ^_^ I like simple.
Go
5
star
29

gossh

command: wraper of ssh, save passwords for users.
Go
5
star
30

gochm

Golang chm version 1.3
5
star
31

httpfs

Go Library for open http file like local file
Go
5
star
32

pngdiff

Golang library png format file diff and patch.
Go
5
star
33

sshgo

通过使用sshpass进行机器间的调整,支持机器名的简写
Python
4
star
34

pm25

get city pm2.5. (I hope one day we will not care about the pm2.5)
JavaScript
4
star
35

adbx

ADB的加强版本,Make ADB more stronger
Go
4
star
36

imutils2

another imutils for opencv simple use
Python
3
star
37

meet-cars

Capture vehicle license plate with ML on the way to work.
Python
3
star
38

docker-goandroid

Dockerfile for golang1.4 android development environment
Go
3
star
39

realip

Get real IP behide nginx (Do not ignore private address)
Go
3
star
40

goshare

share file in current machine.
Go
3
star
41

filedist

智能文件分发工具(smart file distribution)
Go
3
star
42

gen_movie_article

通过提供的电影名列表,结合豆瓣提供的API,生成Markdown文章
Python
3
star
43

bootstrap-tornado

Write a tornado app from a template
Python
3
star
44

monitor

linux系统的监控
Go
3
star
45

github-mirror

For fast get github resource without block.
Go
2
star
46

AutoStock

个人研究和学习股票算法的仓库
Jupyter Notebook
2
star
47

dotfiles

my own dotfiles for linux and mac
Shell
2
star
48

cloudmusic_test_demo

演示教学用
Python
2
star
49

go-websocket

fork of code.google.com/p/go.net/websocket
Go
2
star
50

imageautodemo

Demo of automation based on Image template match
Python
2
star
51

exec

An implement of os/exec, but add timeout option
Go
2
star
52

shweb

Writing web using shell.
Go
2
star
53

webtail

Tail log into web (experimental)
JavaScript
2
star
54

grget

simple online go build
Go
2
star
55

jshunter

javascript static check, based on jslint, output html report
JavaScript
2
star
56

pyignore

Python
2
star
57

muuid

Machine UUID, port of github.com/mhzed/machine-uuid
Go
2
star
58

unsafessh

exec remote command easily.
Go
1
star
59

baidu-prompt-crawler

检查百度关键词
Python
1
star
60

keeprun

Keep console program running.
Go
1
star
61

fibonacci

python simple fibonacci for study of publish python lib
Python
1
star
62

raspi-car

little car controlled by raspberry
Python
1
star
63

shxsun.github.io

Vim Script
1
star
64

pydefer

golang defer implements in python
Python
1
star
65

simple_tornado

为了方便tornado使用的一个库
Python
1
star
66

macaron-jade

Jade template engine for macaron
Go
1
star
67

scripts

scripts of for devop
Shell
1
star
68

gogen

study project. like rails, this is named gails. for quickly golang web develop.
Go
1
star
69

android-snapshot-with-golang

screencap implements with golang
Go
1
star
70

fire

a new project that will replace jetfire
Go
1
star
71

apkdig

Inspect android package information
Go
1
star
72

travelexec

(golang binary bool) travel file tree and call exec (like find + xargs, but offers more functions)
Go
1
star
73

findme

This program help me to find my raspberrypi IP address
Python
1
star
74

py3toolkit

toolkit for my common use
Python
1
star
75

codeskyblue

1
star