- Authors
Mike Dirolf <mike@dirolf.com>, Chris Triolo, and everyone listed in the Credits section below
nginx-gridfs is an Nginx module to serve content directly from MongoDB's GridFS.
nginx-gridfs requires the Mongo-C-Driver which is a submodule to this repository. To check out the submodule (after cloning this repository), run:
$ git submodule init
$ git submodule update
Installing Nginx modules requires rebuilding Nginx from source:
- Grab the Nginx source and unpack it.
- Clone this repository somewhere on your machine.
- Check out the required submodule, as described above.
- Change to the directory containing the Nginx source.
Now build:
$ ./configure --add-module=/path/to/nginx-gridfs/source/ $ make $ make install
Here is the relevant section of an nginx.conf:
location /gridfs/ {
gridfs_db my_app;
# these are the default values:
mongod_host 127.0.0.1;
mongod_port 27017;
gridfs_root_collection fs;
gridfs_field _id; # Supported {_id, filename}
gridfs_type objectid; # Supported {objectid, string, int}
# these are the authentication variables
mongod_user user;
mongod_pass pass;
}
The only required configuration variables is gridfs_db to enable the module for a location and to specify the database in which to store files. mongod_host, mongo_port, gridfs_root_collection, gridfs_field, and gridfs_type can be specified but default to the values given in the configuration above. mongod_user and mongod_pass should be specified only if the database requires authentication.
This will set up Nginx to serve the file in gridfs with _id ObjectId("a12...") for any request to /gridfs/a12...
- Some issues with large files
- HTTP range support for partial downloads
- Better error handling / logging
- Sho Fukamachi (sho) - towards compatibility with newer boost versions
- Olivier Bregeras (stunti) - better handling of binary content
- Chris Heald (cheald) - better handling of binary content
- Paul Dlug (pdlug) - mongo authentication
nginx-gridfs is dual licensed under the Apache License, Version 2.0 and the GNU General Public License, either version 2 or (at your option) any later version. See LICENSE for details.