RoR и nginx

Alex Kitschkiruk rusnginx at gmail.com
Mon Jan 15 02:08:49 MSK 2007


Люди!
хелп...
уже два дня мучаюсь пытабсь соеденить nginx и RubyOnRails через FastCGI.
использую вариант, как с lighttpd, только запускаю nginx. Тут в рассылке
где-то пробегала конфигурация, ее я тоже смотрел.

Так вот, использую что сокеты, что порты все одно - с nginx не запускается.
А точнее всегда выдает 404 ошибку. На том же сокете lighttpd выдает все
нормально.
Такое ощущение, что nginx неправильно передает пути, или DOCUMENT_ROOT не
передает.

Вот что выдает руби:
ActionController::RoutingError (Recognition failed for "/index.html"
req.path=/index.html):
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/routing.rb:523:in
`recognition_failed'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/routing.rb:513:in
`recognize!'
    /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in
`dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/fcgi_handler.rb:150:in
`process_request'
    /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/fcgi_handler.rb:54:in
`process!'
    /usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:612:in `each_cgi'
    /usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:609:in `each'
    /usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:609:in `each_cgi'
    /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/fcgi_handler.rb:53:in
`process!'
    /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/fcgi_handler.rb:23:in
`process!'
    /srv/rb/public/dispatch.fcgi:27

Rendering /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/templates/rescues/layout.rhtml
(404 Page Not Found)


А вот конфиг нгинкса:

server {
        listen  80;
        server_name rb.com;
        root /srv/rb/public/;
        location / {
            include  conf/fastcgi.conf;
            fastcgi_pass unix:/srv/rb/tmp/sockets/fcgi.socket-0;
            fastcgi_index  index.html;
            root /srv/rb/public;
            access_log  /logs/rb.log;
            fastcgi_param  SCRIPT_FILENAME
/srv/rb/public$fastcgi_script_name;
            fastcgi_param  PATH_TRANSLATED
/srv/rb/public$fastcgi_script_name;
            fastcgi_param  SCRIPT_NAME $fastcgi_script_name;
            fastcgi_param  REDIRECT_STATUS 200;
            fastcgi_param  DOCUMENT_ROOT   /srv/rb/public;
            fastcgi_pass_header Authorization;
            fastcgi_intercept_errors off;

            fastcgi_param PATH_INFO             $fastcgi_script_name;
            fastcgi_param REQUEST_METHOD        $request_method;
            fastcgi_param QUERY_STRING          $query_string;
            fastcgi_param CONTENT_TYPE          $content_type;
            fastcgi_param CONTENT_LENGTH        $content_length;
            fastcgi_param SERVER_PORT           $server_port;
            fastcgi_param SERVER_PROTOCOL       $server_protocol;
            fastcgi_param SERVER_NAME           $server_name;

            fastcgi_param REQUEST_URI           $request_uri;
            fastcgi_param DOCUMENT_URI          $document_uri;
            fastcgi_param DOCUMENT_ROOT         $document_root;
            fastcgi_param SERVER_ADDR           $server_addr;
            fastcgi_param REMOTE_USER           $remote_user;
            fastcgi_param REMOTE_ADDR           $remote_addr;
            fastcgi_param REMOTE_PORT           $remote_port;
            fastcgi_param SERVER_SOFTWARE       "nginx";
            fastcgi_param GATEWAY_INTERFACE     "CGI/1.1";
        }
}


У lighttpd в конфиге тоже все просто:

server.bind = "xx.xx.xx.xx"
server.port = 8899

server.modules           = ( "mod_rewrite", "mod_accesslog", "mod_fastcgi",
"mod_compress", "mod_expire" )

server.error-handler-404 = "/dispatch.fcgi"
server.document-root     = CWD + "/public/"

server.errorlog          = CWD + "/log/lighttpd.error.log"
accesslog.filename       = CWD + "/log/lighttpd.access.log"

url.rewrite              = ( "^/$" => "index.html", "^([^.]+)$" => "$1.html"
)

compress.filetype        = ( "text/plain", "text/html", "text/css",
"text/javascript" )
compress.cache-dir       = CWD + "/tmp/cache"

fastcgi.server      = ( ".fcgi" => ( "localhost" => (
  "min-procs"       => 1,
  "max-procs"       => 1,
  "socket"          => CWD + "/tmp/sockets/fcgi.socket",
  "bin-path"        => CWD + "/public/dispatch.fcgi",
  "bin-environment" => ( "RAILS_ENV" => "development" )
) ) )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx-ru/attachments/20070115/2b985522/attachment.html>


More information about the nginx-ru mailing list