# Lighttpd - "Routing Error" in production?

**URL:** <https://www.ruby-forum.com/t/lighttpd-routing-error-in-production/49832>\
**Category:** Rails\
**Created:** [December 9, 2005, 1:51am UTC](https://www.ruby-forum.com/t/lighttpd-routing-error-in-production/49832 "2005-12-09T01:51:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![henryp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e68b1a/32.png) [@henryp](https://www.ruby-forum.com/u/henryp)\
**Post date:** [December 9, 2005, 1:51am UTC](https://www.ruby-forum.com/t/lighttpd-routing-error-in-production/49832/1 "2005-12-09T01:51:26Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![henryp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e68b1a/32.png) [@henryp](https://www.ruby-forum.com/u/henryp)\
**Post date:** [December 14, 2005, 1:03am UTC](https://www.ruby-forum.com/t/lighttpd-routing-error-in-production/49832/2 "2005-12-14T01:03:37Z")

</div>

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](http://localhost:8010/$1) [P,L]

or

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

Should be:

RewriteRule ^/(.\*) [http://10.0.0.50:8010/$1](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 …
