No description
Find a file
2020-12-04 21:44:03 +01:00
assets Remove all google-analytic references 2020-12-04 21:44:03 +01:00
docker fix docker build 2020-10-10 15:05:59 +08:00
scripts add plist proxy 2016-08-01 10:24:06 +08:00
testdata support folder delete, prevent ghs.yml see 2018-09-18 13:35:10 +08:00
.fsw.yml support .ghs.yml add google analytics 2016-08-02 13:34:02 +08:00
.ghs.yml remove 1g limit 2017-09-11 13:40:05 +08:00
.gitignore add version info 2018-09-26 16:10:27 +08:00
.goreleaser.yml set homebrew-tap 2018-09-25 18:51:02 +08:00
.travis.yml change go version to go13 2020-10-10 13:49:51 +08:00
assets_dev.go use vfsgen instead gobindata 2018-09-14 21:03:27 +08:00
assets_generate.go use vfsgen instead gobindata 2018-09-14 21:03:27 +08:00
build.sh fix docker build 2020-10-10 15:05:59 +08:00
go.mod use move instead copy when handle big upload files 2020-10-09 20:05:23 +08:00
httpstaticserver.go Remove all google-analytic references 2020-12-04 21:44:03 +01:00
ipa.go upgrade to go1.11 2018-11-26 10:32:22 +08:00
LICENSE use vfsgen instead gobindata 2018-09-14 21:03:27 +08:00
main.go Remove all google-analytic references 2020-12-04 21:44:03 +01:00
oauth2-proxy.go format code and remove useless code 2019-02-21 20:23:29 +08:00
openid-login.go update doc to latest 2018-09-25 14:35:41 +08:00
Procfile fix procfile 2016-07-30 10:47:40 +08:00
README.md more about the oauth2 proxy mode 2019-02-22 10:54:37 +08:00
res.go add ipa qrcode generate support 2016-07-28 15:24:41 +08:00
utils.go use move instead copy when handle big upload files 2020-10-09 20:05:23 +08:00
utils_test.go fix tests 2016-07-30 09:31:00 +08:00
zip.go unzip ignore .ghs.yml 2019-02-15 17:51:32 +08:00
zip_test.go fix test 2019-02-15 17:41:35 +08:00

gohttpserver

Build Status

  • 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.10, go-1.11

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 get -v github.com/codeskyblue/gohttpserver
cd $GOPATH/src/github.com/codeskyblue/gohttpserver
go build && ./gohttpserver

Or download binaries from github releases

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: "codeskyblue@codeskyblue.com"
  delete: true
  upload: true
  token: 4567gf8asydhf293r23r

In this case, if openid auth is enabled and user "codeskyblue@codeskyblue.com" 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 file=@foo.txt localhost:8000/somedir
{"destination":"somedir/foo.txt","success":true}
# upload with token
$ curl -F file=@foo.txt -F token=12312jlkjafs localhost:8000/somedir
{"destination":"somedir/foo.txt","success":true}

# upload and change filename
$ curl -F file=@foo.txt -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 file=@pkg.zip -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

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 generate .
go build -tags vfs

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.