English 中文(简体)
Lighttpd/FastCGI treating routes as static content
原标题:

I ve come across a frustrating issue with FastCGI and Rails whereby lighttpd is treating routed url s as static files (i.e. not sending them to rails since it believes they re static)

If I hit the root path I get the rails application, but as soon as I hit something with a URL structure, even a path that matches the default :controller/:action route, I get a 404 from lighttpd and the rails app isn t even consulted.

Here s my lighttpd.conf:

server.modules = ( "mod_rewrite", "mod_redirect", "mod_access", "mod_status", "mod_fastcgi", "mod_accesslog" )

server.document-root = "/myapp/application/public"
index-file.names = ( "index.html", "dispatch.fcgi" )
server.error-handler-404 = "/myapp/application/public/404.html"

url.access-deny = ( "~", ".inc" )
server.pid-file = "/var/run/lighttpd.pid"
server.username = "lighttpd"
server.groupname = "lighttpd"

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

#### fastcgi module
fastcgi.server = (
    ".fcgi" => (
        "myapp" => (
            "socket" => "/tmp/myapp.socket",
            "bin-path" => "/myapp/application/public/dispatch.fcgi",
            "check-local" => "disable",
            "fix-root-scriptname" => "true",
            "docroot"=>"/"
        )
    )
)

# mimetype mapping
mimetype.assign = (...)

As for errors, I don t get any at all. Although, if I turn on debugging in Lighttpd, I do see events like these:

2010-01-18 23:11:18: (response.c.261) URI-path     :  /tracking/index 
2010-01-18 23:11:18: (response.c.375) -- before doc_root 
2010-01-18 23:11:18: (response.c.376) Doc-Root     : /myapp/application/tracking/public 
2010-01-18 23:11:18: (response.c.377) Rel-Path     : /tracking/index 
2010-01-18 23:11:18: (response.c.378) Path         :  
2010-01-18 23:11:18: (response.c.426) -- after doc_root 
2010-01-18 23:11:18: (response.c.427) Doc-Root     : /myapp/application/tracking/public 
2010-01-18 23:11:18: (response.c.428) Rel-Path     : /tracking/index 
2010-01-18 23:11:18: (response.c.429) Path         : /myapp/application/tracking/public/tracking/index 
2010-01-18 23:11:18: (response.c.446) -- logical -> physical 
2010-01-18 23:11:18: (response.c.447) Doc-Root     : /myapp/application/tracking/public 
2010-01-18 23:11:18: (response.c.448) Rel-Path     : /tracking/index 
2010-01-18 23:11:18: (response.c.449) Path         : /myapp/application/tracking/public/tracking/index 
2010-01-18 23:11:18: (response.c.466) -- handling physical path 
2010-01-18 23:11:18: (response.c.467) Path         : /myapp/application/tracking/public/tracking/index 
2010-01-18 23:11:18: (response.c.523) -- file not found 
2010-01-18 23:11:18: (response.c.524) Path         : /myapp/application/tracking/public/tracking/index 
2010-01-18 23:11:18: (response.c.205) -- splitting Request-URI 
2010-01-18 23:11:18: (response.c.206) Request-URI  :  /myapp/application/tracking/public/404.html 

Any ideas what could be going wrong?

问题回答

Bit of a facepalm moment there although the documentation doesn t really explain the importance of the server.error-handler setting.

When using fcgi, you need to ensure your error-handler is set to redirect to the fcgi dispatch, else, it ll just show a 404 page.

server.error-handler-404 = "/dispatch.fcgi"

All fixed now.





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签