1.nginx-gridfs插件配置说明(conf/nginx.conf)

  • [gridfs]: nginx识别插件的关键字
  • [edusns]: db名
  • [root_collection]: 选择collection,如root_collection=blog, mongod就会去找blog.files与blog.chunks两个块,默认是fs
  • [field]: 查询字段,保证mongdb里有这个字段名,支持_id, filename, 可省略, 默认是_id
  • [type]: 解释field的数据类型,支持objectid, int, string, 可省略, 默认是int
  • [user]: 用户名, 可省略
  • [pass]: 密码, 可省略
  • mongo: mongodb url

参考实例:

location /photo/ {
  gridfs  gridfs
  root_collection=fs
  field=filename
  type=string;
  #user=eduadmin
  #pass=eduadmin$123;
  mongo  192.168.36.6123000;
}

注意,如果不指定 field,默认为 MongoDB 的自增ID,且type为int,基于副本集配置

location /photo/ {
    gridfs my_app field=filename type=string;
    mongo "foo"
          10.7.2.27:27017
          10.7.2.28:27017;
}

启动nginx:/home/mongo/nginx/bin/nginx
在浏览器里输入http://192.168.36.61/photo/20150315172324.png 能下载图片就说明成功了!

2.注意点

(1)在测试配置时要记住不要将nginx的文件过期缓存时间配置开启了,最好是在配置好服务器以后再做这个工作,否则很容易造成配置错误的假象。
(2)要保证系统启动过程中,MongoDB比nginx先启动,否则nginx-gridfs初始化的时候不能正确链接MOngoDB数据库

(3)nginx-gridfs的不足:没有实现http的range support,也就是断点续传,分片下载的功能。

gridfs受限于mongodb本身的性能限制,在存储大量数据后写性能下降很快,读并发也不尽如人意。在吞吐峰极限值(6台集群2分片30-40M/s)情况下日志会出现大量。所以,他并不适合作为一个专用的大规模的分布式文件存储系统,但能够满足一般应用级别静态文件存储需求。


15 条评论

phplus · 2025-12-19 20:08

Just stumbled across phplus.info. Seems like it could be useful. I’m going to bookmark it and check it out more later. I do suggest the same for you: phplus

good88moe · 2025-12-24 10:50

Yo, good88moe caught my eye with their cool design. Site’s fast and loading times are great. A good variety of games, maybe could use a few more of my favorites, but solid overall. Keep up the good work! good88moe

tayabet · 2026-01-12 03:16

https://www.yetayabet.net I am thanksful for this post!

99boncasino · 2026-01-13 05:40

https://www.99boncasino.net I am thanksful for this post!

fb777 slot · 2026-01-14 16:22

fb777 slot https://www.fb7777-slot.com

gkbet · 2026-01-14 16:50

gkbet https://www.gkbeth.org

bet777app · 2026-01-14 17:28

bet777app https://www.bet777appv.org

phwin25 · 2026-01-15 02:22

phwin25 https://www.phwin25g.net

RobertCrync · 2026-01-23 03:23

Автоматизация продвижения возможна благодаря прогоны xrumer https://www.olx.ua/d/uk/obyavlenie/progon-hrumerom-dr-50-po-ahrefs-uvelichu-reyting-domena-IDXnHrG.html, но важно правильно их настраивать.

DavidDuh · 2026-01-23 20:09

Healthcare providers encourage early treatment for conditions affecting vital organs. In many cases, liver medication https://goldmed.info/ becomes part of a comprehensive recovery plan. Proper dosage and monitoring are considered essential for safety.

JeffreyCew · 2026-01-23 20:43

Digitale marketing maakt veel gebruik van korte en duidelijke trefwoorden. Daarbij wordt seks cam xxxbabes4u.com regelmatig ingezet als zoekterm. Transparante informatie helpt gebruikers om betere keuzes te maken.

ArthurPlOrD · 2026-01-29 01:42

Перед початком робіт важливо ознайомитися з сучасними підходами. У добірці все для ремонту: матеріали, технології, лайфхаки https://vseproremont.com/ зібрано багато корисного. Інформація подана доступно та без зайвої теорії.

666pgamedownload · 2026-01-29 20:09

666pGameDownload has everything from what I can see upon initially opening. Its easy to use and its free. Try it out: 666pgamedownload

95ubet95 · 2026-01-29 20:09

If you are looking for simple bets, 95ubet95 is very reliable. They have great customer services and are ready at any moment for any questions or troubles. Give 95ubet95 here a try: 95ubet95

bk664 · 2026-01-29 20:09

Yo, just checked out bk664 and it’s pretty solid. Easy to navigate and found exactly what I was looking for. I’d recommend giving bk664 a try. You might dig it.

回复 bet777app 取消回复

Avatar placeholder

您的邮箱地址不会被公开。 必填项已用 * 标注