support try_files #10

Open
benbro opened this Issue Jun 9, 2010 · 3 comments

3 participants

@benbro

try_files allow you to server a static file but if it doesn't exists pass the request
to the app server.
It'll be useful to have something similar in nginx-gridfs.

try_files syntax (http://wiki.nginx.org/NginxHttpCoreModule#try_files):
location / {
try_files index.html index.htm @fallback;
}

location @fallback {
root /var/www/error;
index index.html;
}

thanks

@mdirolf
Owner

makes sense - will see if chris can take a look at this

@benbro

The use case is using gridfs as a cache for user avatars of different sizes.
If ngind-gridfs can't find the file in gridfs, it'll pass the request to a script that creates the image and store it in gridfs.
Subsequent requests will be served from gridfs directly.

The syntax for try_files is:
try_files $uri @fallback;

The equivalent syntax for gridfx could be:
location /gridfs/ {
gridfs my_app field=filename type=string fallback=@fallback;
mongo 127.0.0.1:27017;
}

location @fallback {
# a script that will create the image and store it in gridfs
proxy_pass http://localhost:8000;
}

Is there a chance you can look at it?
Without it, I can't use this module and gridfs.
With @fallback implemented, this is a killer.

@alangarf

Why don't you just do this instead?


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment