nginx & ror

Timur Vafin timurv at gmail.com
Thu Aug 24 14:21:46 MSD 2006


Здравствуйте, nginx-ru.

Хочется подружить nginx + RubyOnRails, а точнее mongrel_rails

В чем заключается задача:
 1. Все файлы не существующие в root проксировать
 2. Те что есть, отдавать без проксирования
 3. Плюс есть такая вещь как кеш, т.е. если пришел запрос
 /controller/action и в root нет такаго файла, но есть
 /controller/action.html, нужно без проксирования отдать /controller/action.html

 Попытался реализовать, но 3 пункт как то не хочет работать...

upstream  test {
    server   localhost:3000;
    server   localhost:3001;
    server   localhost:3002;
    server   localhost:3003;
    server   localhost:3004;
}

server {
    listen              tsweb.toa:81;
    server_name         test.tsweb.toa;

    # path to static files
    root                /home/timurv/work/projects/test/public;

    # for correct / requests
    index               /index.html;

    # all exists static files send with nginx
    # other proxy to mongrel
    error_page          404     = /not_found_mongrel_handler;

    location /not_found_mongrel_handler {
        set $cached_request_filename $request_filename.html;

        # вот тут почему то всегда истинное условие
        if (!-f $cached_request_filename) {
            proxy_pass  http://test;
            break;
        }

        rewrite     ^(.*)$  $1.html;
    }
}
 

-- 
С уважением,
 Timur                          mailto:timurv at gmail.com






More information about the nginx-ru mailing list