GridFS Nginx comprueba si existen datos

I use (File System Based) static html files for caching, for some reasons i don like this. I want store cache files (html, images) in database.

Now it work like that:

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

It looks like this in my Nginx config file

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

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

It's posible to do IF check with GridFS Or Amazon S3 or Mysql or anything alse?

Muchas gracias

AND THE ANSWER IS

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;                  
}  

preguntado el 08 de noviembre de 11 a las 16:11

One more Good answer is here github.com/mdirolf/nginx-gridfs/issues/10 -

1 Respuestas

Puede utilizar el nginx-gridfs module to serve GridFS files directly from Nginx, and then catch a 404 for files not found and proxy those to the other server.

respondido 08 nov., 11:20

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.