Nginx-GridFS踩坑记录

1,254 阅读1分钟

nginx和nginx-gridfs都装好了,有些坑可能和版本有很大关系

Nginx重新编译安装后访问不了了

把项目配置文件的导入注释掉,直接用最小配置测试

server {
    listen       80;
    server_name  www.wyyxhlxy.com;
    location / {
        root   html;
        index  index.html index.htm;
    }
    location /grid/ {
        gridfs test user=test pass=test;
    }
}

无响应

nginx状态

netstat -anp|grep nginx

tcp       21      0 0.0.0.0:80              0.0.0.0:*               LISTEN      14998/nginx: master

日志

2019/05/30 16:24:04 [notice] 28031#0: signal process started
2019/05/30 16:24:04 [error] 28032#0: Invalid mongo user/pass: test/test
2019/05/30 16:24:04 [alert] 14998#0: worker process 28032 exited with fatal code 2 and cannot be respawned

说明因为mongodb密码问题nginx服务启动失败了。

密码是对的为什么会失败呢?

由此想到了mongodb3.0之后换了密码验证算法。查了一下,果然。

目前Nginx-gridfs插件只支持MongoDB2.6.9附近版本,Nginx版本只支持1.14.2

这位老哥提供了一个方案,但是一定要用2.6.9的版本。我认为3一下应该都行,毕竟大概率是验证算法的锅。

nginx-gridfs是最后一次维护是在六年前,很老了,这个库其实并应该不推荐使用。

我不想一直用mongodb2.x,所以现在考虑用其他的方案。