mdirolf / nginx-gridfs

Nginx module for serving files from MongoDB's GridFS
http://www.mongodb.org
Other
794 stars 147 forks source link

nginx can`t access mongodb #52

Open FreedZou opened 11 years ago

FreedZou commented 11 years ago

gridfs

I`ve installed nginx-gridfs module

when I access the picture,the result is error 404 and error_log of nginx like this:

2013/04/19 17:12:26 [error] 8349#0: *7658 Mongo connection dropped, could not reconnect, client: 221.226.28.34, server: localhost, request: "GET /xxoo/test.gif HTTP/1.1", host: "suishen.mobi"

Is the problem of the nginx-gridfs module?

I need help! Thanks!

the picture has been storaged in mongodb image

pic access url http://domain/xxoo/test.gif

nginx configure image

eguven commented 11 years ago

Can you connect to that database using mongo shell?

mongo 10.1.1.1:30000/xxoo
alp82 commented 10 years ago

Same issue here. @eguven Yes, i am able to connect to that database using mongo shell.

Did you manage to find the solution to this?

generalChow commented 10 years ago

me too , i have same problem, do you find the solution to this,i need your help

alp82 commented 10 years ago

I emailed the owner of this repository. It seems like he does not have time to work on current issues anymore. I will look into Riak CS as a drop-in replacement for MongoDB Gridfs.

rdkls commented 10 years ago

Had the same problem Found commit 76225528b3903fc9eafcb8163c7ebfdf34237e8b works, my config:

location /grid/ {
    gridfs assets;
    mongo 172.16.1.154;
}

I notice at this stage it can't however resolve using avahi, only IP.

alp82 commented 10 years ago

@rdkls I am not sure how this is supposed to be a fix. The commit was already merged into master 2 years ago. What should i do if my config is:

location /grid/ {
    gridfs mediafiles field=filename type=string;
    mongo 172.16.1.154:27123;
}
rdkls commented 10 years ago

Sorry for not fixing your problems =) It's something that works for me, at least. If I were you, I would check out that commit, recompile, and see if it works! Please also note the readme on the front of the repo - the owner is no longer actively maintaining it. So if you want something fixed - DIY.

assen-totin commented 10 years ago

To fix the isseu you need the latest master branch of the C driver (the GridFS module uses another branch, which seems to be faulty).

After cloning this repo, do not do 'git submodule init && git subodule update', but instead: git clone https://github.com/eagleas/mongo-c-driver.git

Then compile nginx as usual.

alp82 commented 10 years ago

That's great assen73, thank you very much for your help.

mainliner commented 10 years ago

thank you very much for assen73's help

assen-totin commented 10 years ago

Guys, I might have stumbled onto something while playing with another MongoDB library, which is in pure C... I had a case much like this - the GridFS driver was seeing the file, but returning a size of 0 for it; it turned out that the file size in GridFS size was stored by some drivers as LongInt() and by others as Int(). On 64-bit platforms both work fine, but on 32-bit Little-endian platforms this breaks interoperability, because if the driver expects the size to be LongInt (64 bits), but it is Int (32 bits), then it often returns a size of 0. This means that the driver reading the GridFS should check how the size is stored and interpret it properly. I'm not sure if this is the case here, but it may be worth checking - as the fix will be easy.

mainliner commented 10 years ago

There are one problem is that you must delete the -Werror option of gcc in [nginx-source/objs/MakeFile]. If you don't do that, the warning will be treated as errors when you do make.

the log of make below:

cc1: warnings being treated as errors /home/Administrator/upload/nginx-gridfs//mongo-c-driver/src/numbers.c gcc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Wunused-function -Wunused-variable -Wunused-value -Werror -g --std=c99 -Isrc -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/ngx_modules.o \ make[1]: *\ [objs/addon/src/mongo.o] Error 1

ilaipi commented 10 years ago

I got an error : nginx-gridfs/mongo-c-driver/src/bson.c:632:28: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] if ( pos + bytesNeeded <= b->dataSize ) how colud I do?

I do :git clone https://github.com/eagleas/mongo-c-driver.git
instead of 'git submodule init && git subodule update'

Have anyone help me?

foxinmy commented 9 years ago

@mz0827 please use nginx1.4.7 or earlier version.

V-Alexeev commented 9 years ago

@ilaipi you can refer to this issue: https://github.com/barakav/gridfs-nginx-plugin/issues/1

(to quote the answer in that thread: add (unsigned long) in the places there is a comparison issue to the int side. (if ( pos + bytesNeeded <= (unsigned long) b->dataSize )))

sumantfordev commented 8 years ago

i am trying this ..but getting the mongo connection drop error eventhough when i cloned git mongo-c-driver module instead of init and update.. I have a 64 bit ubuntu machine and using nginx 1.10.1 version of the nginx code.

zhusas commented 8 years ago

@sumantfordev I also encountered the same problem, the problem is that the mongo-c-driver driver,it can't use https://github.com/mongodb/mongo-c-driver.git Only use https://github.com/eagleas/mongo-c-driver.git

sumantfordev commented 8 years ago

Thanks i will give it a shot with it... Also is there any module to upload content to gridfs. Not looking to use lua but a direct nginx gridfs module as this one .. but to upload

weiztech commented 7 years ago

13:10:05 [error] 14472#0: 5 Mongo connection dropped, could not reconnect, client: 127.0.0.1, server: localhost, request: "GET /gridfs/label2.jpeg HTTP/1.1", host: "localhost" 2017/02/26 13:10:05 [alert] 14472#0: 5 header already sent while sending response to client, client: 127.0.0.1, server: localhost, request: "GET /gridfs/label2.jpeg HTTP/1.1", host: "localhost"

13:10:06 [error] 14472#0: 6 Mongo connection dropped, could not reconnect, client: 127.0.0.1, server: localhost, request: "GET /gridfs/label2.jpeg HTTP/1.1", host: "localhost" 2017/02/26 13:10:06 [alert] 14472#0: 6 header already sent while sending response to client, client: 127.0.0.1, server: localhost, request: "GET /gridfs/label2.jpeg HTTP/1.1", host: "localhost"`

have similiar issue, i'm using nginx1.11