Skip to content

Instantly share code, notes, and snippets.

@rhelmer
Last active September 9, 2016 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhelmer/00dd0f9e4076260078367f763bc9aaf3 to your computer and use it in GitHub Desktop.
Save rhelmer/00dd0f9e4076260078367f763bc9aaf3 to your computer and use it in GitHub Desktop.

Requirements

Building

$ apt-get build-dep nginx
$ apt-get source nginx
$ cd nginx/debian/modules
$ git clone https://github.com/vkholodkov/nginx-upload-module
$ cd nginx-upload-module; git checkout 2.2; cd ../
$ git clone https://github.com/cybozu/nginx-uuid4-module
$ cd ../../
$ vi debian/rules

Add the new modules:

--add-module=../nginx-uuid4-module \
--add-module=../nginx-upload-module

Build new .deb:

$ dpkg-buildpackage

Install

$ sudo dpkg -i ../nginx-common_1.10.0-0ubuntu0.16.04.2_all.deb ../nginx-extras_1.10.0-0ubuntu0.16.04.2_amd64.deb 

Configuration

Add an upload endpoint in nginx configuration in /etc/nginx/sites-available/default:

location /upload {
    uuid4 $crash_id;
    upload_store /tmp 1;
    return 200 $crash_id;
}

Testing

Now try uploading a file and ensure that a UUID is returned:

curl -F "key=val" http://localhost/upload/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment