【问题标题】:GridFS Nginx check if data existGridFS Nginx 检查数据是否存在
【发布时间】:2011-12-24 14:48:45
【问题描述】:

我使用(基于文件系统的)静态 html 文件进行缓存,出于某些原因,我不喜欢这样。我想在数据库中存储缓存文件(html、图像)。

现在它是这样工作的:

if nginx can get cache:
    return cache to user
else
    proxy_pass request to backend server

在我的 Nginx 配置文件中看起来像这样

if (-f $cache_dir_prefix/$query) {
    rewrite (.*) $query break;
}

if (!-f $cache_dir_prefix/$query) {
    proxy_pass http://lionyzer;
    break;
}

是否可以使用 GridFS 或 Amazon S3 或 Mysql 或其他任何东西进行 IF 检查?

非常感谢

答案是

location /assets/ {                                                                             
    gridfs assets field=filename type=string;                                            
    mongo 127.0.0.1:27017;                                                                      
    error_page 404 = @scale;                                                                    
}                                                                                               

location @scale {                                                                               
    include fastcgi.conf;                                                                       
    fastcgi_pass unix:/tmp/php-fpm;                                                             
    fastcgi_param SCRIPT_FILENAME scaleme.php;                  
}  

【问题讨论】:

标签: nginx gridfs


【解决方案1】:

您可以使用nginx-gridfs 模块直接从 Nginx 提供 GridFS 文件,然后使用catch a 404 for files not found 并将这些文件代理到其他服务器。

【讨论】:

    猜你喜欢
    • 2015-10-22
    • 1970-01-01
    • 1970-01-01
    • 2021-11-30
    • 2020-09-24
    • 2014-07-08
    • 2019-06-24
    • 2014-04-03
    相关资源
    最近更新 更多