2010-01-18 57 views
0

我遇到一個令人沮喪的問題,FastCGI的和Rails藉此lighttpd的是治療路由地址的靜態文件(即不發送他們導軌因爲它認爲他們是靜態)Lighttpd的/ FastCGI的治療路徑爲靜態內容

如果我點擊根路徑,我得到了rails應用程序,但是當我用URL結構打開某些東西時,即使是匹配默認值:controller /:action route的路徑,我也從lighttpd獲得了404,而rails應用程序isn甚至沒有諮詢過。

這裏是我的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 = (...) 

至於錯誤,我沒有得到任何人在所有。 雖然,如果我打開在Lighttpd的調試,我確實看到這樣的事件:

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 

任何想法可能是想錯了?

回答

0

雖然文檔並沒有真正解釋server.error處理程序設置的重要性,但它仍然存在於facepalm那一刻。

使用fcgi時,您需要確保您的錯誤處理程序設置爲重定向到fcgi分派,否則,它將只顯示一個404頁面。

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

現在全部修好了。

+0

請注意,使用「server.error-handler-N」時,將錯誤頁面視爲完全限定的請求。他們將代碼「200」返回給所有請求。要真正能夠通過正確的值返回帶有錯誤代碼的頁面,您應該使用「server.errorfile-prefix」,在這裏聲明一個帶有錯誤編號作爲文件名稱(即「404.html」)的html文件的文件夾。 – user1254893 2012-04-02 11:12:26