Lighttpd - "Routing Error" in production?


#1

I’m running Lighttpd for an app behind an Apache proxy … even though
I’m in production mode I get “Routing Error” for non-existent pages
instead of 404s. Any ideas? Thanks much in advance …

httpd.conf:

<VirtualHost 10.0.0.50:80>
DocumentRoot “/data/wwwroot/railsapp.lan/public”
ServerName railsapp.lan
RewriteEngine On
ProxyPreserveHost On
RewriteRule ^/(.*) http://localhost:8010/$1 [P,L]

lighttpd.conf:

server.username = “nobody”
server.groupname = “nobody”
server.port = 8010
server.bind = “0.0.0.0”
server.pid-file = “/data/wwwroot/railsapp.lan/tmp/lighttpd.pid”
server.modules = ( “mod_rewrite”,
“mod_redirect”,
“mod_access”,
“mod_auth”,
“mod_fastcgi”,
“mod_accesslog”
)
server.document-root = “/data/wwwroot/footballsquares.lan/public/”
server.indexfiles = ( “dispatch.fcgi”, “index.html” )
accesslog.filename = “/www/logs/lighttpd_8010_access.log”
server.errorlog = “/www/logs/lighttpd_8010_error.log”
server.error-handler-404 = “/dispatch.fcgi”

fastcgi.server = (
“.fcgi” => (
“localhost” => (
“bin-environment” => ( “RAILS_ENV” => “production”,
“LD_LIBRARY_PATH” => “/usr/local/lib” ),
“socket” => “/data/wwwroot/railsapp.lan/tmp/lighttpd.socket”,
“bin-path” => “/data/wwwroot/railsapp.lan/public/dispatch.fcgi”,
“min-procs” => 1,
“max_procs” => 5
)
)
)

mimetype.assign = (
“.rpm” => “application/x-rpm”,
“.pdf” => “application/pdf”,
#… etc


#2

Here’s the fix: In the Apache vhost directive redirect to the local IP
address instead of localhost or 127.0.0.1. Otherwise Rails thinks
you’re local and spits out development environment-like 404s.

So instead of

RewriteRule ^/(.*) http://localhost:8010/$1 [P,L]

or

RewriteRule ^/(.*) http://127.0.0.1:8010/$1 [P,L]

Should be:

RewriteRule ^/(.*) http://10.0.0.50:8010/$1 [P,L]

Henry wrote:

I’m running Lighttpd for an app behind an Apache proxy … even though
I’m in production mode I get “Routing Error” for non-existent pages
instead of 404s. Any ideas? Thanks much in advance …