Created
April 25, 2018 07:52
-
-
Save kindy/f7042187fc15d28601b27734a1a1bc5d to your computer and use it in GitHub Desktop.
Revisions
-
kindy created this gist
Apr 25, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ # Simple File Server(upload) / 简易文件服务器(支持上传) 一般文件上传都会使用 Form 形式, 其实如果只是为了做一个简单的文件服务的话,那么可以简化许多。 Nginx 默认提供了文件访问服务,使用 autoindex 可以提供文件list 功能; 对于文件上传,使用 [WebDAV](https://nginx.org/en/docs/http/ngx_http_dav_module.html)模块可以极大简化上传的实现及用法。 ## Nginx 配置 ``` server { listen 80; root /main/ss_root; location ~ ^/files/ { autoindex on; autoindex_exact_size off; client_body_in_file_only on; client_body_temp_path /main/ss_body_temp; dav_methods PUT; create_full_put_path on; dav_access group:rw all:r; } } ``` ## 用法 文件的查看和浏览使用浏览器即可 ### 上传 ``` curl -X PUT -T path/to/local.png http://ip/files/path/on/server.png ```