@@ -36,34 +36,67 @@ Installing Nginx modules requires rebuilding Nginx from source:
36
36
37
37
Configuration
38
38
=============
39
- Here is the relevant section of an *nginx.conf *::
39
+
40
+ **gridfs **
41
+
42
+ :syntax: *gridfs DB_NAME [root_collection=ROOT] [field=QUERY_FIELD] [type=QUERY_TYPE] [user=USERNAME] [pass=PASSWORD] *
43
+ :default: *NONE *
44
+ :context: location
45
+
46
+ This directive enables the **nginx-gridfs ** module at a given location. The
47
+ only required parameter is DB_NAME to specify the database to serve files from.
48
+
49
+ * *root_collection= * specify the root_collection(prefix) of the GridFS. default: *fs *
50
+ * *field= * specify the field to query. Supported fields include *_id * and *filename *. default: *_id *
51
+ * *type= * specify the type to query. Supported types include *objectid *, *string * and *int *. default: *objectid *
52
+ * *user= * specify a username if your mongo database requires authentication. default: *NULL *
53
+ * *pass= * specify a password if your mongo database requires authentication. default: *NULL *
54
+
55
+ **mongo **
56
+
57
+ :syntax: *mongo MONGOD_HOST *
58
+ :default: *127.0.0.1:27017 *
59
+ :context: location
60
+
61
+ This directive specifies a mongod to connect to. MONGOD_HOST should be in the
62
+ form of hostname:port. This directive is optional.
63
+
64
+ Here is a sample configuration in the relevant section of an *nginx.conf *::
40
65
41
66
location /gridfs/ {
42
- gridfs_db my_app;
43
-
44
- # these are the default values:
45
- mongod_host 127.0.0.1;
46
- mongod_port 27017;
47
- gridfs_root_collection fs;
48
- gridfs_field _id; # Supported {_id, filename}
49
- gridfs_type objectid; # Supported {objectid, string, int}
50
-
51
- # these are the authentication variables
52
- mongod_user user;
53
- mongod_pass pass;
67
+ gridfs my_app;
54
68
}
55
69
56
- The only required configuration variables is **gridfs_db ** to enable
57
- the module for a location and to specify the database in which to
58
- store files. **mongod_host **, **mongo_port **, **gridfs_root_collection **,
59
- **gridfs_field **, and **gridfs_type ** can be specified but default to
60
- the values given in the configuration above. **mongod_user ** and
61
- **mongod_pass ** should be specified only if the database requires
62
- authentication.
63
-
64
70
This will set up Nginx to serve the file in gridfs with _id *ObjectId("a12...") *
65
71
for any request to */gridfs/a12... *
66
72
73
+ Here is another configuration::
74
+
75
+ location /gridfs/ {
76
+ gridfs my_app field=filename type=string;
77
+ mongo 127.0.0.1:27017;
78
+ }
79
+
80
+ This will set up Nginx to serve the file in gridfs with filename *foo *
81
+ for any request to */gridfs/foo *
82
+
83
+ Here is another configuration::
84
+
85
+ location /gridfs/ {
86
+ gridfs my_app
87
+ root_collection=pics
88
+ field=_id
89
+ type=int
90
+ user=foo
91
+ pass=bar;
92
+ mongo 127.0.0.1:27017;
93
+ }
94
+
95
+ This will set up Nginx to communicate with the mongod at 127.0.0.1:27017 and
96
+ authenticate use of database *my_app * with username/password combo *foo/bar *.
97
+ The gridfs root_collection is specified as *pics *. Nginx will then serve the
98
+ file in gridfs with _id *123... * for any request to */gridfs/123... *
99
+
67
100
Known Issues / TODO / Things You Should Hack On
68
101
===============================================
69
102
0 commit comments