# Lighttpd Conf Help - Multiple Domains Multiple Apps

**URL:** <https://www.ruby-forum.com/t/lighttpd-conf-help-multiple-domains-multiple-apps/65469>\
**Category:** Rails\
**Created:** [August 18, 2006, 2:49pm UTC](https://www.ruby-forum.com/t/lighttpd-conf-help-multiple-domains-multiple-apps/65469 "2006-08-18T14:49:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sombrero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@sombrero](https://www.ruby-forum.com/u/sombrero)\
**Post date:** [August 18, 2006, 2:49pm UTC](https://www.ruby-forum.com/t/lighttpd-conf-help-multiple-domains-multiple-apps/65469/1 "2006-08-18T14:49:50Z")

</div>

Hi Guys,

I hope someone can help me out. I am trying to configure two  
applications to run on lighttpd and each app will have its own domain.  
My machine is running on Fedora. When I run my lighttpd with the  
following conf file, I get no error but when I check out my app, it  
dishes out a 404 error- the 404 being served isn’t the 404 inside the  
railsapp/public folder.

Do hope someone can help me out what’s wrong with my conf. Here it is:

server.bind = “0.0.0.0”  
server.port = 8282  
server.modules = ( “mod\_rewrite”, “mod\_accesslog”,  
“mod\_fastcgi”, “mod\_compress”, “mod\_expire” )  
server.pid-file = “/var/run/lighttpd.pid”

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

#commenting the line below gives out an error that says: “a default  
document-root has to be set”  
server.document-root = “/path/to/rails/app1/public/”

compress.filetype = ( “text/plain”, “text/html”, “text/css”,  
“text/javascript” )  
#I temporarily commented out the compress and expire methods  
#compress.cache-dir = CWD + “/tmp/cache”  
#expire.url = ( “/favicon.ico” =\> “access 3 days”,

# “/images/” =\> “access 3 days”,

# “/stylesheets/” =\> “access 3 days”,

# “/javascripts/” =\> “access 3 days” )

# Change \*-procs to 2 if you need to use Upload Progress or other tasks

that

# _need_ to execute a second request while the first is still pending.

mimetype.assign = (  
“.css” =\> “text/css”,  
“.gif” =\> “image/gif”,  
“.htm” =\> “text/html”,  
“.html” =\> “text/html”,  
“.jpeg” =\> “image/jpeg”,  
“.jpg” =\> “image/jpeg”,  
“.js” =\> “text/javascript”,  
“.png” =\> “image/png”,  
“.swf” =\> “application/x-shockwave-flash”,  
“.txt” =\> “text/plain”  
)

# Making sure file uploads above 64k always work when using IE or Safari

# For more information, see [http://trac.lighttpd.net/trac/ticket/360](http://trac.lighttpd.net/trac/ticket/360)

$HTTP[“useragent”] =~ “^(._MSIE._)|(._AppleWebKit._)$” {  
#Server.max-keep-alive-requests = 0  
server.max-keep-alive-requests = 128  
server.max-keep-alive-idle = 30  
server.max-read-idle = 60  
server.max-write-idle = 360  
server.max-fds = 2048  
}

$HTTP[“host”] =~ “(^|.)mysite1.com$” {  
server.document-root = “/path/to/rails/app1” #notice the public folder  
wasn’t stated here  
server.errorlog = “/var/log/lighttpd/mysite1.com/error.log”  
accesslog.filename = “/var/log/lighttpd/mysite1.com/lighttpd.access.log”  
compress.cache-dir = “/path/to/rails/app1/tmp/cache”  
server.error-handler-404 = “/dispatch.fcgi”  
fastcgi.server = ( “.fcgi” =\> ( “localhost” =\> (  
“min-procs” =\> 1,  
“max-procs” =\> 1,  
“socket” =\> “/path/to/rails/app1/tmp/sockets/fcgi.socket”,  
“bin-path” =\> “/path/to/rails/app1/public/dispatch.fcgi”,  
“bin-environment” =\> ( “RAILS\_ENV” =\> “development” )  
) ) )  
}  
$HTTP[“host”] =~ “(^|.)mysite2.com$” {  
server.document-root = “/path/to/rails/app2”  
server.errorlog = “/var/log/lighttpd/mysite2.com/error.log”  
accesslog.filename = “/var/log/lighttpd/mysite2.com/lighttpd.access.log”  
server.error-handler-404 = “/e404.html”  
#compress.cache-dir = “/tmp/cache”  
#fastcgi.server = ( “.fcgi” =\> ( “localhost” =\> (

# “min-procs” =\> 1,

# “max-procs” =\> 1,

# “socket” =\> “/path/to/rails/app2/tmp/sockets/fcgi.socket”,

# “bin-path” =\> “/path/to/rails/app2/public/dispatch.fcgi”,

# “bin-environment” =\> ( “RAILS\_ENV” =\> “development” )

#) ) )  
}

---

<div class="post-metadata">

**Author:** ![sombrero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@sombrero](https://www.ruby-forum.com/u/sombrero)\
**Post date:** [August 23, 2006, 12:59am UTC](https://www.ruby-forum.com/t/lighttpd-conf-help-multiple-domains-multiple-apps/65469/2 "2006-08-23T00:59:14Z")

</div>

Bing, add these directives to your lighttpd.conf:

debug.log-file-not-found = “enable”  
debug.log-request-header = “enable”  
debug.log-response-header = “enable”  
debug.log-request-handling = “enable”

then restart lighttpd.

Run this from the command line of your server:

tail -f /var/log/lighttpd/lighttpd.access.log

Then try to go to your domain and watch the output in your ssh session.  
Watch what lighttpd does with your request. Make certain that when the  
“File Not Found” shows up in your access log that lighttpd properly  
hands the problem over to dispatch.fcgi (the path to dispatch.fcgi must  
be correct as well).

Additionally I don’t see the server.groupname or server.username set in  
your config - I’m not certain if that is causing your problem, but set  
those if they need to be (I needed them).

I was able to figure out my problems using the debug. directives - so  
try those first.

Hope that helps,

Charles

---

<div class="post-metadata">

**Author:** ![sombrero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@sombrero](https://www.ruby-forum.com/u/sombrero)\
**Post date:** [August 18, 2006, 8:13pm UTC](https://www.ruby-forum.com/t/lighttpd-conf-help-multiple-domains-multiple-apps/65469/3 "2006-08-18T20:13:38Z")

</div>

Hi Bing,

Obscuring the file / directory paths is making it difficult for me to  
help you out with your config (if you are not obscuring your directories

- then I suggest you make certain they are all right).

But what I can do is suggest that you use mod\_simple\_vhost — you can  
grab my conf file and learn a bit about it at

[http://www.forthecode.com/user/comment/22](http://www.forthecode.com/user/comment/22)

This config works fine for me - you can just ignore the stuff about  
being behind Apache2 (and just set the port lighttpd listens on to the  
correct one).

Regards,

Charles

Bing T. wrote:

> Hi Guys,
> 
> I hope someone can help me out. I am trying to configure two  
> applications to run on lighttpd and each app will have its own domain.  
> My machine is running on Fedora. When I run my lighttpd with the  
> following conf file, I get no error but when I check out my app, it  
> dishes out a 404 error- the 404 being served isn’t the 404 inside the  
> railsapp/public folder.
> 
> Do hope someone can help me out what’s wrong with my conf. Here it is:
> 
> server.bind = “0.0.0.0”  
> server.port = 8282  
> server.modules = ( “mod\_rewrite”, “mod\_accesslog”,  
> “mod\_fastcgi”, “mod\_compress”, “mod\_expire” )  
> server.pid-file = “/var/run/lighttpd.pid”
> 
> url.rewrite = ( “^/$” =\> “index.html”, “^([^.]+)$” =\>  
> “$1.html” )
> 
> #commenting the line below gives out an error that says: “a default  
> document-root has to be set”  
> server.document-root = “/path/to/rails/app1/public/”
> 
> compress.filetype = ( “text/plain”, “text/html”, “text/css”,  
> “text/javascript” )  
> #I temporarily commented out the compress and expire methods  
> #compress.cache-dir = CWD + “/tmp/cache”  
> #expire.url = ( “/favicon.ico” =\> “access 3 days”,
> 
> # “/images/” =\> “access 3 days”,
> 
> # “/stylesheets/” =\> “access 3 days”,
> 
> # “/javascripts/” =\> “access 3 days” )
> 
> # Change \*-procs to 2 if you need to use Upload Progress or other tasks
> 
> that
> 
> # _need_ to execute a second request while the first is still pending.
> 
> mimetype.assign = (  
> “.css” =\> “text/css”,  
> “.gif” =\> “image/gif”,  
> “.htm” =\> “text/html”,  
> “.html” =\> “text/html”,  
> “.jpeg” =\> “image/jpeg”,  
> “.jpg” =\> “image/jpeg”,  
> “.js” =\> “text/javascript”,  
> “.png” =\> “image/png”,  
> “.swf” =\> “application/x-shockwave-flash”,  
> “.txt” =\> “text/plain”  
> )
> 
> # Making sure file uploads above 64k always work when using IE or Safari
> 
> # For more information, see [http://trac.lighttpd.net/trac/ticket/360](http://trac.lighttpd.net/trac/ticket/360)
> 
> $HTTP[“useragent”] =~ “^(._MSIE._)|(._AppleWebKit._)$” {  
> #Server.max-keep-alive-requests = 0  
> server.max-keep-alive-requests = 128  
> server.max-keep-alive-idle = 30  
> server.max-read-idle = 60  
> server.max-write-idle = 360  
> server.max-fds = 2048  
> }
> 
> $HTTP[“host”] =~ “(^|.)mysite1.com$” {  
> server.document-root = “/path/to/rails/app1” #notice the public folder  
> wasn’t stated here  
> server.errorlog = “/var/log/lighttpd/mysite1.com/error.log”  
> accesslog.filename = “/var/log/lighttpd/mysite1.com/lighttpd.access.log”  
> compress.cache-dir = “/path/to/rails/app1/tmp/cache”  
> server.error-handler-404 = “/dispatch.fcgi”  
> fastcgi.server = ( “.fcgi” =\> ( “localhost” =\> (  
> “min-procs” =\> 1,  
> “max-procs” =\> 1,  
> “socket” =\> “/path/to/rails/app1/tmp/sockets/fcgi.socket”,  
> “bin-path” =\> “/path/to/rails/app1/public/dispatch.fcgi”,  
> “bin-environment” =\> ( “RAILS\_ENV” =\> “development” )  
> ) ) )  
> }  
> $HTTP[“host”] =~ “(^|.)mysite2.com$” {  
> server.document-root = “/path/to/rails/app2”  
> server.errorlog = “/var/log/lighttpd/mysite2.com/error.log”  
> accesslog.filename = “/var/log/lighttpd/mysite2.com/lighttpd.access.log”  
> server.error-handler-404 = “/e404.html”  
> #compress.cache-dir = “/tmp/cache”  
> #fastcgi.server = ( “.fcgi” =\> ( “localhost” =\> (
> 
> # “min-procs” =\> 1,
> 
> # “max-procs” =\> 1,
> 
> # “socket” =\> “/path/to/rails/app2/tmp/sockets/fcgi.socket”,
> 
> # “bin-path” =\> “/path/to/rails/app2/public/dispatch.fcgi”,
> 
> # “bin-environment” =\> ( “RAILS\_ENV” =\> “development” )
> 
> #) ) )  
> }

---

<div class="post-metadata">

**Author:** ![sombrero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@sombrero](https://www.ruby-forum.com/u/sombrero)\
**Post date:** [August 22, 2006, 12:31pm UTC](https://www.ruby-forum.com/t/lighttpd-conf-help-multiple-domains-multiple-apps/65469/4 "2006-08-22T12:31:33Z")

</div>

Hi Charles,

I tried the vhost and it’s still not working. Here is my conf again,  
hopefully this is much clearer. We played around with and currently with  
this config I’m still getting the 404.html.

# Default configuration file for the lighttpd web server

# Start using ./script/server lighttpd

server.bind = “0.0.0.0”  
server.port = 8282  
server.modules = ( “mod\_rewrite”, “mod\_accesslog”,  
“mod\_fastcgi”)  
server.document-root =  
“/var/www/vhosts/domain1.com/httpdocs/railsapp1/public/”  
server.errorlog = “/var/log/lighttpd/lighttpd.error.log”  
accesslog.filename = “/var/log/lighttpd/lighttpd.access.log”  
url.rewrite = ( “^/$” =\> “index.html”, “^([^.]+)$” =\>  
“$1.html” )

mimetype.assign = (  
“.css” =\> “text/css”,  
“.gif” =\> “image/gif”,  
“.htm” =\> “text/html”,  
“.html” =\> “text/html”,  
“.jpeg” =\> “image/jpeg”,  
“.jpg” =\> “image/jpeg”,  
“.js” =\> “text/javascript”,  
“.png” =\> “image/png”,  
“.swf” =\> “application/x-shockwave-flash”,  
“.txt” =\> “text/plain”  
)

# Making sure file uploads above 64k always work when using IE or Safari

# For more information, see [http://trac.lighttpd.net/trac/ticket/360](http://trac.lighttpd.net/trac/ticket/360)

$HTTP[“useragent”] =~ “^(._MSIE._)|(._AppleWebKit._)$” {  
#Server.max-keep-alive-requests = 0  
server.max-keep-alive-requests = 128  
server.max-keep-alive-idle = 30  
server.max-read-idle = 60  
server.max-write-idle = 360  
server.max-fds = 2048

}

$HTTP[“host”] =~ “(^|.)domain1.com$” {  
server.document-root =  
“/var/www/vhosts/domain1.com/httpdocs/railsapp1/public/”  
server.error-handler-404 = “/dispatch.fcgi”  
fastcgi.server = ( “.fcgi” =\> ( “localhost” =\> (  
“min-procs” =\> 1,  
“max-procs” =\> 1,  
“socket” =\>  
“/var/www/vhosts/domain1.com/httpdocs/railsapp1/tmp/sockets/fcgi.socket”,  
“bin-path” =\>  
“/var/www/vhosts/domain1.com/httpdocs/railsapp1/public/dispatch.fcgi”,  
“bin-environment” =\> ( “RAILS\_ENV” =\> “development” )  
) ) )  
}  
$HTTP[“host”] =~ “(^|.)domain2.com$” {  
server.document-root =  
“/var/www/vhosts/domain2.com/httpdocs/railsapp2/public/”  
server.error-handler-404 = “/dispatch.fcgi”  
fastcgi.server = ( “.fcgi” =\> ( “localhost” =\> (  
“min-procs” =\> 1,  
“max-procs” =\> 1,  
“socket” =\>  
“/var/www/vhosts/domain1.com/httpdocs/railsapp1/tmp/sockets/fcgi.socket”,  
“bin-path” =\>  
“/var/www/vhosts/domain1.com/httpdocs/railsapp1/public/dispatch.fcgi”,  
“bin-environment” =\> ( “RAILS\_ENV” =\> “development” )  
) ) )  
}

Bing
